mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-21 22:30:46 +08:00
feat(ipinfo): support GeoIP (#26)
Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
+2
-2
@@ -6,8 +6,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/li4n0/revsuit/internal/database"
|
||||
"github.com/li4n0/revsuit/internal/ipinfo"
|
||||
"github.com/li4n0/revsuit/internal/newdns"
|
||||
"github.com/li4n0/revsuit/internal/qqwry"
|
||||
"github.com/li4n0/revsuit/internal/recycler"
|
||||
"github.com/li4n0/revsuit/internal/rule"
|
||||
"github.com/patrickmn/go-cache"
|
||||
@@ -135,7 +135,7 @@ func (s *Server) newZone(name string) *newdns.Zone {
|
||||
continue
|
||||
}
|
||||
|
||||
r, err := newRecord(_rule, flag, domain, ip, qqwry.Area(ip))
|
||||
r, err := newRecord(_rule, flag, domain, ip, ipinfo.Area(ip))
|
||||
if err != nil {
|
||||
log.Warn("DNS record(rule_id:%s) created failed :%s", _rule.Name, err)
|
||||
return nil, nil
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/li4n0/revsuit/internal/database"
|
||||
"github.com/li4n0/revsuit/internal/file"
|
||||
"github.com/li4n0/revsuit/internal/ipinfo"
|
||||
"github.com/li4n0/revsuit/internal/notice"
|
||||
"github.com/li4n0/revsuit/internal/qqwry"
|
||||
"github.com/li4n0/revsuit/internal/record"
|
||||
log "unknwon.dev/clog/v2"
|
||||
)
|
||||
@@ -137,7 +137,7 @@ func ListRecords(c *gin.Context) {
|
||||
|
||||
func createRecord(_rule *Rule, flag, flagGroup, user, password, method, path, filename, ip string, uploadData []byte, status Status) {
|
||||
// create new record
|
||||
area := qqwry.Area(ip)
|
||||
area := ipinfo.Area(ip)
|
||||
var ftpFile *file.FTPFile
|
||||
var r *Record
|
||||
var err error
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/li4n0/revsuit/internal/database"
|
||||
"github.com/li4n0/revsuit/internal/file"
|
||||
"github.com/li4n0/revsuit/internal/qqwry"
|
||||
"github.com/li4n0/revsuit/internal/ipinfo"
|
||||
"github.com/li4n0/revsuit/pkg/mysql/vmysql"
|
||||
"github.com/pkg/errors"
|
||||
log "unknwon.dev/clog/v2"
|
||||
@@ -130,7 +130,7 @@ func (s *Server) ConnectionClosed(c *vmysql.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
r, err := newRecord(_rule, flag, user, schema, clientName, clientOS, ip, qqwry.Area(ip), supportLoadLocalData, files)
|
||||
r, err := newRecord(_rule, flag, user, schema, clientName, clientOS, ip, ipinfo.Area(ip), supportLoadLocalData, files)
|
||||
if err != nil {
|
||||
log.Warn("MySQL record[rule_id: %s] created failed: %s", _rule.Name, err)
|
||||
return
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/li4n0/revsuit/internal/database"
|
||||
"github.com/li4n0/revsuit/internal/qqwry"
|
||||
"github.com/li4n0/revsuit/internal/ipinfo"
|
||||
log "unknwon.dev/clog/v2"
|
||||
)
|
||||
|
||||
@@ -174,7 +174,7 @@ func (s *Server) Receive(c *gin.Context) {
|
||||
}
|
||||
|
||||
// create new record
|
||||
r, err := NewRecord(_rule, flag, c.Request.Method, u, ip, qqwry.Area(ip), string(raw))
|
||||
r, err := NewRecord(_rule, flag, c.Request.Method, u, ip, ipinfo.Area(ip), string(raw))
|
||||
if err != nil {
|
||||
log.Warn("HTTP record[rule_id:%d] created failed :%s", _rule.ID, err)
|
||||
code, err := strconv.Atoi(compileTpl(c, _rule.ResponseStatusCode, vars))
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/li4n0/revsuit/internal/database"
|
||||
"github.com/li4n0/revsuit/internal/qqwry"
|
||||
"github.com/li4n0/revsuit/internal/ipinfo"
|
||||
"github.com/li4n0/revsuit/internal/recycler"
|
||||
"github.com/pkg/errors"
|
||||
log "unknwon.dev/clog/v2"
|
||||
@@ -111,7 +111,7 @@ func (s *Server) handleConnection(conn net.Conn) {
|
||||
continue
|
||||
}
|
||||
|
||||
area := qqwry.Area(ip)
|
||||
area := ipinfo.Area(ip)
|
||||
|
||||
// create new record
|
||||
r, err := NewRecord(_rule, flag, path, ip, area)
|
||||
|
||||
+16
-14
@@ -1,6 +1,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/li4n0/revsuit/internal/ipinfo"
|
||||
"github.com/li4n0/revsuit/pkg/dns"
|
||||
"github.com/li4n0/revsuit/pkg/ftp"
|
||||
"github.com/li4n0/revsuit/pkg/mysql"
|
||||
@@ -16,18 +17,19 @@ type noticeConfig struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Version float64
|
||||
Addr string
|
||||
Token string
|
||||
Domain string
|
||||
ExternalIP string `yaml:"external_ip"`
|
||||
AdminPathPrefix string `yaml:"admin_path_prefix"`
|
||||
Database string
|
||||
LogLevel string `yaml:"log_level"`
|
||||
Notice noticeConfig
|
||||
HTTP rhttp.Config
|
||||
DNS dns.Config
|
||||
MySQL mysql.Config
|
||||
RMI rmi.Config
|
||||
FTP ftp.Config
|
||||
Version float64
|
||||
Addr string
|
||||
Token string
|
||||
Domain string
|
||||
ExternalIP string `yaml:"external_ip"`
|
||||
AdminPathPrefix string `yaml:"admin_path_prefix"`
|
||||
Database string
|
||||
LogLevel string `yaml:"log_level"`
|
||||
IpLocationDatabase ipinfo.Config `yaml:"ip_location_database"`
|
||||
Notice noticeConfig
|
||||
HTTP rhttp.Config
|
||||
DNS dns.Config
|
||||
MySQL mysql.Config
|
||||
RMI rmi.Config
|
||||
FTP ftp.Config
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/li4n0/revsuit/internal/database"
|
||||
"github.com/li4n0/revsuit/internal/file"
|
||||
"github.com/li4n0/revsuit/internal/ipinfo"
|
||||
"github.com/li4n0/revsuit/internal/notice"
|
||||
"github.com/li4n0/revsuit/internal/record"
|
||||
"github.com/li4n0/revsuit/pkg/dns"
|
||||
@@ -178,6 +179,7 @@ func New(c *Config) *Revsuit {
|
||||
|
||||
initDatabase(c.Database)
|
||||
logLevel := initLog(c.LogLevel)
|
||||
ipinfo.Init(c.IpLocationDatabase)
|
||||
initNotice(c.Notice)
|
||||
|
||||
s := &Revsuit{
|
||||
|
||||
Reference in New Issue
Block a user