mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-26 16:41:53 +08:00
release revsuit vBeta0.1.0 (#15)
Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
@@ -1 +1,10 @@
|
||||
package cli
|
||||
|
||||
const banner = `
|
||||
____ _____ _ __
|
||||
/ __ \___ _ __/ ___/__ __(_) /_
|
||||
/ /_/ / _ \ | / /\__ \/ / / / / __/
|
||||
/ _, _/ __/ |/ /___/ / /_/ / / /_
|
||||
/_/ |_|\___/|___//____/\__,_/_/\__/
|
||||
v%s
|
||||
https://revsuit.pro`
|
||||
|
||||
+26
-6
@@ -1,16 +1,21 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
|
||||
"github.com/li4n0/revsuit/pkg/server"
|
||||
"github.com/urfave/cli/v2"
|
||||
"gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
log "unknwon.dev/clog/v2"
|
||||
)
|
||||
|
||||
func Start() {
|
||||
_ = log.NewConsole(100,
|
||||
log.ConsoleConfig{
|
||||
Level: log.LevelInfo,
|
||||
})
|
||||
app := &cli.App{
|
||||
Name: "RevSuit",
|
||||
Usage: "An Open-Sourced Reverse Platform Designed for Receive Various Kinds of Connection",
|
||||
@@ -23,21 +28,32 @@ func Start() {
|
||||
Name: "token",
|
||||
Usage: "token used to manage platform",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "flags",
|
||||
Usage: "for http and dns connection, platform will only record the connection those match these regex flags. * meaning record all",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "db",
|
||||
Usage: "database file path",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "log",
|
||||
Usage: "specify a log level from debug, info, warn, error, fatal. (default: info)",
|
||||
},
|
||||
&cli.PathFlag{
|
||||
Name: "config",
|
||||
Usage: "load configuration from FILE (default: config.yaml)",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
var configFile = "config.yaml"
|
||||
if c.Path("config") != "" {
|
||||
configFile = c.Path("config")
|
||||
}
|
||||
conf := &server.Config{}
|
||||
if content, err := os.ReadFile("config.yaml"); err == nil {
|
||||
if content, err := os.ReadFile(configFile); err == nil {
|
||||
if err := yaml.Unmarshal(content, conf); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if os.IsNotExist(err) && configFile == "config.yaml" {
|
||||
log.Warn("Generate default configurations to config.yaml, please configure and run again.")
|
||||
return os.WriteFile("config.yaml", configTemplate, 0644)
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
@@ -50,6 +66,10 @@ func Start() {
|
||||
if c.String("db") != "" {
|
||||
conf.Database = c.String("db")
|
||||
}
|
||||
if c.String("log") != "" {
|
||||
conf.Database = c.String("log")
|
||||
}
|
||||
fmt.Printf(banner, server.VERSION)
|
||||
server.New(conf).Run()
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
version: 4.0
|
||||
addr: :10000
|
||||
token:
|
||||
database: revsuit.db
|
||||
log_level: info
|
||||
|
||||
http:
|
||||
ip_header:
|
||||
dns:
|
||||
enable: true
|
||||
rmi:
|
||||
enable: true
|
||||
addr: :1099
|
||||
mysql:
|
||||
enable: true
|
||||
addr: :3306
|
||||
version_string: 10.4.13-MariaDB-log
|
||||
ftp:
|
||||
enable: true
|
||||
addr: :21
|
||||
pasv_ip: 127.0.0.1 # your public network ip
|
||||
pasv_port: 2020
|
||||
notice:
|
||||
dingtalk: https://oapi.dingtalk.com/robot/send?access_token={token}
|
||||
lark: https://open.feishu.cn/open-apis/bot/v2/hook/{token}
|
||||
weixin: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={key}
|
||||
slack: https://hooks.slack.com/services/{id}/{token}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed config.tpl.yaml
|
||||
var configTemplate []byte
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/li4n0/revsuit/internal/record"
|
||||
"github.com/pkg/errors"
|
||||
log "unknwon.dev/clog/v2"
|
||||
)
|
||||
|
||||
@@ -14,6 +15,7 @@ var (
|
||||
|
||||
// Bot is used to send notice
|
||||
type Bot interface {
|
||||
name() string
|
||||
notice(record.Record) error
|
||||
buildPayload(record.Record) string
|
||||
}
|
||||
@@ -41,7 +43,7 @@ func (a *Announcer) AddBot(b Bot) *Announcer {
|
||||
func Notice(r record.Record) {
|
||||
for _, bot := range announcer.Bots {
|
||||
if err := bot.notice(r); err != nil {
|
||||
log.Warn(err.Error())
|
||||
log.Warn(errors.Wrap(err, "%s notice failed").Error(), bot.name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ type dingPayload struct {
|
||||
At []dingAt `json:"at"`
|
||||
}
|
||||
|
||||
func (d *DingTalk) name() string {
|
||||
return "DingTalk"
|
||||
}
|
||||
|
||||
func (d *DingTalk) buildPayload(r record.Record) string {
|
||||
payload := dingPayload{
|
||||
MsgType: "markdown",
|
||||
|
||||
@@ -41,7 +41,11 @@ type larkPayload struct {
|
||||
Card larkCard `json:"card"`
|
||||
}
|
||||
|
||||
func (d *Lark) buildPayload(r record.Record) string {
|
||||
func (l *Lark) name() string {
|
||||
return "Lark"
|
||||
}
|
||||
|
||||
func (l *Lark) buildPayload(r record.Record) string {
|
||||
payload := larkPayload{
|
||||
MsgType: "interactive",
|
||||
Card: larkCard{
|
||||
@@ -69,8 +73,8 @@ func (d *Lark) buildPayload(r record.Record) string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (d *Lark) notice(r record.Record) error {
|
||||
resp, err := http.Post(d.URL, "application/json", strings.NewReader(d.buildPayload(r)))
|
||||
func (l *Lark) notice(r record.Record) error {
|
||||
resp, err := http.Post(l.URL, "application/json", strings.NewReader(l.buildPayload(r)))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "HTTP request")
|
||||
}
|
||||
|
||||
@@ -36,7 +36,11 @@ type slackPayload struct {
|
||||
Attachments []slackAttachments `json:"attachments"`
|
||||
}
|
||||
|
||||
func (d *Slack) buildPayload(r record.Record) string {
|
||||
func (s *Slack) name() string {
|
||||
return "Slack"
|
||||
}
|
||||
|
||||
func (s *Slack) buildPayload(r record.Record) string {
|
||||
payload := slackPayload{
|
||||
Attachments: []slackAttachments{
|
||||
{
|
||||
@@ -67,8 +71,8 @@ func (d *Slack) buildPayload(r record.Record) string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (d *Slack) notice(r record.Record) error {
|
||||
resp, err := http.Post(d.URL, "application/json", strings.NewReader(d.buildPayload(r)))
|
||||
func (s *Slack) notice(r record.Record) error {
|
||||
resp, err := http.Post(s.URL, "application/json", strings.NewReader(s.buildPayload(r)))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "HTTP request")
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ type weixinPayload struct {
|
||||
Markdown weixinMarkdown `json:"markdown"`
|
||||
}
|
||||
|
||||
func (w *Weixin) name() string {
|
||||
return "Weixin"
|
||||
}
|
||||
|
||||
func (w *Weixin) buildPayload(r record.Record) string {
|
||||
payload := weixinPayload{
|
||||
ToUser: "@all",
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
COPY_WRITE_URL = "https://qqwry.mirror.noc.one/copywrite.rar"
|
||||
QQWRY_URL = "https://qqwry.mirror.noc.one/qqwry.rar"
|
||||
CopyWriteUrl = "https://qqwry.mirror.noc.one/copywrite.rar"
|
||||
QqwryUrl = "https://qqwry.mirror.noc.one/qqwry.rar"
|
||||
)
|
||||
|
||||
func get(url string) (b []byte, err error) {
|
||||
@@ -70,14 +70,14 @@ func download() (err error) {
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if copyWriteData, err = get(COPY_WRITE_URL); err != nil {
|
||||
if copyWriteData, err = get(CopyWriteUrl); err != nil {
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if qqwryData, err = get(QQWRY_URL); err != nil {
|
||||
if qqwryData, err = get(QqwryUrl); err != nil {
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -13,6 +13,10 @@ var wry *qqwry.QQwry
|
||||
var once sync.Once
|
||||
|
||||
func init() {
|
||||
_ = log.NewConsole(100,
|
||||
log.ConsoleConfig{
|
||||
Level: log.LevelInfo,
|
||||
})
|
||||
info, err := os.Stat("qqwry.dat")
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
@@ -14,15 +14,15 @@ type Rule interface {
|
||||
}
|
||||
|
||||
type BaseRule struct {
|
||||
Rule `gorm:"-" json:"-"`
|
||||
ID uint `gorm:"primarykey" form:"id" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Rule `gorm:"-" json:"-" yaml:"-"`
|
||||
ID uint `gorm:"primarykey" form:"id" json:"id" yaml:"-"`
|
||||
CreatedAt time.Time `json:"created_at" yaml:"-"`
|
||||
UpdatedAt time.Time `json:"updated_at" yaml:"-"`
|
||||
Name string `gorm:"index;unique;not null;" form:"name" json:"name"`
|
||||
FlagFormat string `gorm:"unique;not null;" form:"flag_format" json:"flag_format"`
|
||||
FlagFormat string `gorm:"unique;not null;" form:"flag_format" json:"flag_format" yaml:"flag_format"`
|
||||
flagCatcher *regexp.Regexp `gorm:"-" json:"-"`
|
||||
Rank int `gorm:"default:0" json:"rank" form:"rank"`
|
||||
PushToClient bool `gorm:"default:false;not null;" form:"push_to_client" json:"push_to_client"`
|
||||
PushToClient bool `gorm:"default:false;not null;" form:"push_to_client" json:"push_to_client" yaml:"push_to_client"`
|
||||
Notice bool `gorm:"default:false;not null;" form:"notice" json:"notice"`
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func (br BaseRule) Match(s string) (flag, flagGroup string, vars map[string]stri
|
||||
}
|
||||
|
||||
flag = matched[0]
|
||||
if len(matched) > 1 && len(groupNames) == 0 {
|
||||
if len(matched) > 1 && groupNames[1] == "" {
|
||||
flagGroup = matched[1]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user