mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 12:42:27 +08:00
code cleanup
This commit is contained in:
parent
68b28ed530
commit
64be213b66
@ -22,7 +22,7 @@ type Listener struct {
|
|||||||
var _listener *Listener
|
var _listener *Listener
|
||||||
|
|
||||||
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (*Listener, error) {
|
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (*Listener, error) {
|
||||||
addr, cipher, password, err := parseSSURL(config)
|
addr, cipher, password, err := ParseSSURL(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func (c *packet) InAddr() net.Addr {
|
|||||||
return c.pc.LocalAddr()
|
return c.pc.LocalAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseSSURL(s string) (addr, cipher, password string, err error) {
|
func ParseSSURL(s string) (addr, cipher, password string, err error) {
|
||||||
u, err := url.Parse(s)
|
u, err := url.Parse(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/adapter/inbound"
|
"github.com/Dreamacro/clash/adapter/inbound"
|
||||||
@ -34,7 +33,7 @@ type Listener struct {
|
|||||||
var _listener *Listener
|
var _listener *Listener
|
||||||
|
|
||||||
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (C.AdvanceListener, error) {
|
func New(config string, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (C.AdvanceListener, error) {
|
||||||
addr, cipher, password, err := parseSSURL(config)
|
addr, cipher, password, err := embedSS.ParseSSURL(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -159,17 +158,3 @@ func HandleShadowSocks(conn net.Conn, in chan<- C.ConnContext) bool {
|
|||||||
}
|
}
|
||||||
return embedSS.HandleShadowSocks(conn, in)
|
return embedSS.HandleShadowSocks(conn, in)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseSSURL(s string) (addr, cipher, password string, err error) {
|
|
||||||
u, err := url.Parse(s)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
addr = u.Host
|
|
||||||
if u.User != nil {
|
|
||||||
cipher = u.User.Username()
|
|
||||||
password, _ = u.User.Password()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user