mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-21 22:30:46 +08:00
feat: add domain and external ip configuration items (#18)
This commit is contained in:
+9
-3
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
type Server struct {
|
||||
Config
|
||||
pasvIP string
|
||||
rules []*Rule
|
||||
rulesLock sync.RWMutex
|
||||
livingLock sync.Mutex
|
||||
@@ -55,6 +56,11 @@ func GetServer() *Server {
|
||||
return server
|
||||
}
|
||||
|
||||
func (s *Server) SetPasvIP(ip string) *Server {
|
||||
s.pasvIP = ip
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Server) getRules() []*Rule {
|
||||
defer s.rulesLock.RUnlock()
|
||||
s.rulesLock.RLock()
|
||||
@@ -194,10 +200,10 @@ loop:
|
||||
_, _ = connBuf.WriteString(UserLogged)
|
||||
|
||||
if pasvAddress = s.getPasvAddressFromCache(ip, _rule.PasvAddress); pasvAddress == "" {
|
||||
pasvAddress = fmt.Sprintf("%s:%d", s.PasvIP, s.PasvPort)
|
||||
pasvAddress = fmt.Sprintf("%s:%d", s.pasvIP, s.PasvPort)
|
||||
}
|
||||
|
||||
isRedirect = rule.CompileTpl(pasvAddress, vars) != fmt.Sprintf("%s:%d", s.PasvIP, s.PasvPort)
|
||||
isRedirect = rule.CompileTpl(pasvAddress, vars) != fmt.Sprintf("%s:%d", s.pasvIP, s.PasvPort)
|
||||
case "SIZE":
|
||||
path += strings.TrimLeft(args, "/")
|
||||
if _rule == nil || isRedirect || len(_rule.Data) == 0 {
|
||||
@@ -312,7 +318,7 @@ func (s *Server) handlePasvConnection(conn net.Conn, data map[string]interface{}
|
||||
// run pasv server
|
||||
func (s *Server) runPasvServer() (net.Listener, error) {
|
||||
pasvAddress := fmt.Sprintf("%s:%d", strings.Split(s.Addr, ":")[0], s.PasvPort)
|
||||
log.Info("Start to listen FTP PASV port at %v, PasvIP is %v", pasvAddress, s.PasvIP)
|
||||
log.Info("Start to listen FTP PASV port at %v, PasvIP is %v", pasvAddress, s.pasvIP)
|
||||
listener, err := net.Listen("tcp", pasvAddress)
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user