mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-18 08:20:53 +00:00
update
This commit is contained in:
parent
e28d0089db
commit
ea7ad8a93b
8 changed files with 11 additions and 39 deletions
BIN
compile/clash
Normal file
BIN
compile/clash
Normal file
Binary file not shown.
|
@ -197,7 +197,6 @@ type Config struct {
|
|||
TLS *TLS
|
||||
|
||||
WanInput *inbound.WanInput
|
||||
TlsUser []auth.AuthUser
|
||||
}
|
||||
|
||||
type RawNTP struct {
|
||||
|
@ -623,9 +622,6 @@ func ParseRawConfig(rawCfg *RawConfig) (*Config, error) {
|
|||
|
||||
config.Users = parseAuthentication(rawCfg.Authentication)
|
||||
|
||||
if rawCfg.WanInput.Port != 0 {
|
||||
config.TlsUser = parseAuthentication(rawCfg.WanInput.Authentication)
|
||||
}
|
||||
config.WanInput = &rawCfg.WanInput
|
||||
|
||||
config.Tunnels = rawCfg.Tunnels
|
||||
|
|
|
@ -91,7 +91,6 @@ func ApplyConfig(cfg *config.Config, force bool) {
|
|||
}
|
||||
|
||||
updateUsers(cfg.Users)
|
||||
updateUsersTls(cfg.TlsUser)
|
||||
updateProxies(cfg.Proxies, cfg.Providers)
|
||||
updateRules(cfg.Rules, cfg.SubRules, cfg.RuleProviders)
|
||||
updateSniffer(cfg.Sniffer)
|
||||
|
@ -425,14 +424,6 @@ func updateUsers(users []auth.AuthUser) {
|
|||
}
|
||||
}
|
||||
|
||||
func updateUsersTls(users []auth.AuthUser) {
|
||||
authenticator := auth.NewAuthenticator(users)
|
||||
authStore.SetAuthenticatorTls(authenticator)
|
||||
if authenticator != nil {
|
||||
log.Infoln("Authentication tls of local server updated")
|
||||
}
|
||||
}
|
||||
|
||||
func updateProfile(cfg *config.Config) {
|
||||
profileCfg := cfg.Profile
|
||||
|
||||
|
|
|
@ -5,17 +5,11 @@ import (
|
|||
)
|
||||
|
||||
var authenticator auth.Authenticator
|
||||
var authenticatorTls auth.Authenticator
|
||||
|
||||
func Authenticator() auth.Authenticator {
|
||||
return authenticator
|
||||
}
|
||||
func AuthenticatorTls() auth.Authenticator {
|
||||
return authenticatorTls
|
||||
}
|
||||
|
||||
func SetAuthenticator(au auth.Authenticator) {
|
||||
authenticator = au
|
||||
}
|
||||
func SetAuthenticatorTls(au auth.Authenticator) {
|
||||
authenticatorTls = au
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ func handleConnTls(conn net.Conn, tlsProxy *inbound.TLSProxy, tunnel C.Tunnel) {
|
|||
return
|
||||
}
|
||||
if head[0] == socks5.Version {
|
||||
socks.HandleSocks5Tls(myConn, tunnel)
|
||||
socks.HandleSocks5(myConn, tunnel)
|
||||
} else {
|
||||
defer myConn.Close()
|
||||
|
||||
|
|
|
@ -62,11 +62,13 @@ func InitSShServer(tunnel_ C.Tunnel) {
|
|||
}
|
||||
|
||||
func passwordHandler(ctx ssh.Context, password string) bool {
|
||||
author := authStore.AuthenticatorTls()
|
||||
author := authStore.Authenticator()
|
||||
if inbound.SkipAuthRemoteAddr(ctx.RemoteAddr()) {
|
||||
author = nil
|
||||
}
|
||||
if author == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
if author.Verify(ctx.User(), password) {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -98,11 +98,12 @@ func HandleSocks4(conn net.Conn, tunnel C.Tunnel, additions ...inbound.Addition)
|
|||
if inbound.SkipAuthRemoteAddr(conn.RemoteAddr()) {
|
||||
authenticator = nil
|
||||
}
|
||||
addr, _, _, err := socks4.ServerHandshake(conn, authenticator)
|
||||
addr, _, user, err := socks4.ServerHandshake(conn, authenticator)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
additions = append(additions, inbound.WithInUser(user))
|
||||
tunnel.HandleTCPConn(inbound.NewSocket(socks5.ParseAddr(addr), conn, C.SOCKS4, additions...))
|
||||
}
|
||||
|
||||
|
@ -111,7 +112,7 @@ func HandleSocks5(conn net.Conn, tunnel C.Tunnel, additions ...inbound.Addition)
|
|||
if inbound.SkipAuthRemoteAddr(conn.RemoteAddr()) {
|
||||
authenticator = nil
|
||||
}
|
||||
target, command, _, err := socks5.ServerHandshake(conn, authenticator)
|
||||
target, command, user, err := socks5.ServerHandshake(conn, authenticator)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return
|
||||
|
@ -121,19 +122,6 @@ func HandleSocks5(conn net.Conn, tunnel C.Tunnel, additions ...inbound.Addition)
|
|||
io.Copy(io.Discard, conn)
|
||||
return
|
||||
}
|
||||
additions = append(additions, inbound.WithInUser(user))
|
||||
tunnel.HandleTCPConn(inbound.NewSocket(target, conn, C.SOCKS5, additions...))
|
||||
}
|
||||
|
||||
func HandleSocks5Tls(conn net.Conn, tunnel C.Tunnel) {
|
||||
target, command, _, err := socks5.ServerHandshake(conn, authStore.AuthenticatorTls())
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
if command == socks5.CmdUDPAssociate {
|
||||
defer conn.Close()
|
||||
io.Copy(io.Discard, conn)
|
||||
return
|
||||
}
|
||||
tunnel.HandleTCPConn(inbound.NewSocket(target, conn, C.SOCKS5))
|
||||
}
|
||||
|
|
1
main.go
1
main.go
|
@ -49,6 +49,7 @@ func init() {
|
|||
flag.BoolVar(&geodataMode, "m", false, "set geodata mode")
|
||||
flag.BoolVar(&version, "v", false, "show current version of mihomo")
|
||||
flag.BoolVar(&testConfig, "t", false, "test configuration and exit")
|
||||
flag.StringVar(&service, "s", "", "Service control action: status, install (as a service), uninstall (as a service), start(in daemon), stop(daemon), restart(stop then start)")
|
||||
flag.Parse()
|
||||
|
||||
flagset = map[string]bool{}
|
||||
|
|
Loading…
Add table
Reference in a new issue