mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-12-01 11:06:50 +00:00
chore: adjust struct name
This commit is contained in:
1 parent
ad730ae974
commit
aff8dc73e1
41 files changed
+60
-60
No files matched your search
@@ -37,19 +37,19 @@ func MPTCP() bool {
|
||||
|
||||
type controlFn = func(network, address string, c syscall.RawConn) error
|
||||
|
||||
type ListenerConfig struct {
|
||||
type ListenConfig struct {
|
||||
routeMark int
|
||||
}
|
||||
|
||||
func NewListenerConfig() *ListenerConfig {
|
||||
return &ListenerConfig{}
|
||||
func NewListenConfig() *ListenConfig {
|
||||
return &ListenConfig{}
|
||||
}
|
||||
|
||||
func (l *ListenerConfig) SetRouteMark(mark int) {
|
||||
func (l *ListenConfig) SetRouteMark(mark int) {
|
||||
l.routeMark = mark
|
||||
}
|
||||
|
||||
func (l ListenerConfig) newListenConfig() *tfo.ListenConfig {
|
||||
func (l ListenConfig) newListenConfig() *tfo.ListenConfig {
|
||||
lc := tfo.ListenConfig{DisableTFO: !Tfo()}
|
||||
keepalive.SetNetListenConfig(&lc.ListenConfig)
|
||||
mptcp.SetNetListenConfig(&lc.ListenConfig, MPTCP())
|
||||
@@ -65,7 +65,7 @@ func (l ListenerConfig) newListenConfig() *tfo.ListenConfig {
|
||||
return &lc
|
||||
}
|
||||
|
||||
func (l ListenerConfig) Listen(ctx context.Context, network, address string) (net.Listener, error) {
|
||||
func (l ListenConfig) Listen(ctx context.Context, network, address string) (net.Listener, error) {
|
||||
address, err := preResolve(network, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -73,7 +73,7 @@ func (l ListenerConfig) Listen(ctx context.Context, network, address string) (ne
|
||||
return l.newListenConfig().Listen(ctx, network, address)
|
||||
}
|
||||
|
||||
func (l ListenerConfig) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error) {
|
||||
func (l ListenConfig) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error) {
|
||||
address, err := preResolve(network, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ func (s *Server) SetService(service resolver.Service) {
|
||||
s.service = service
|
||||
}
|
||||
|
||||
func ReCreateServer(addr string, lc *inbound.ListenerConfig, service resolver.Service) {
|
||||
func ReCreateServer(addr string, lc *inbound.ListenConfig, service resolver.Service) {
|
||||
if addr == address && service != nil {
|
||||
server.SetService(service)
|
||||
return
|
||||
|
||||
@@ -297,7 +297,7 @@ func updateDNS(c *config.DNS, generalIPv6 bool) {
|
||||
resolver.DirectHostResolver = r.Resolver
|
||||
}
|
||||
|
||||
lc := inbound.NewListenerConfig()
|
||||
lc := inbound.NewListenConfig()
|
||||
lc.SetRouteMark(c.ListenRoutingMark)
|
||||
dns.ReCreateServer(c.Listen, lc, s)
|
||||
}
|
||||
|
||||
+3
-3
@@ -168,7 +168,7 @@ func start(cfg *Config) {
|
||||
|
||||
// handle addr
|
||||
if len(cfg.Addr) > 0 {
|
||||
lc := inbound.NewListenerConfig()
|
||||
lc := inbound.NewListenConfig()
|
||||
lc.SetRouteMark(cfg.RoutingMark)
|
||||
l, err := lc.Listen(context.Background(), "tcp", cfg.Addr)
|
||||
if err != nil {
|
||||
@@ -202,7 +202,7 @@ func startTLS(cfg *Config) {
|
||||
return
|
||||
}
|
||||
|
||||
lc := inbound.NewListenerConfig()
|
||||
lc := inbound.NewListenConfig()
|
||||
lc.SetRouteMark(cfg.RoutingMark)
|
||||
l, err := lc.Listen(context.Background(), "tcp", cfg.TLSAddr)
|
||||
if err != nil {
|
||||
@@ -276,7 +276,7 @@ func startUnix(cfg *Config) {
|
||||
// should be used to delete the socket file prior to calling bind with the same path.
|
||||
_ = syscall.Unlink(addr)
|
||||
|
||||
lc := inbound.NewListenerConfig()
|
||||
lc := inbound.NewListenConfig()
|
||||
lc.SetRouteMark(0) // don't set route mark for unix socket
|
||||
l, err := lc.Listen(context.Background(), "unix", addr)
|
||||
if err != nil {
|
||||
|
||||
@@ -35,7 +35,7 @@ type Listener struct {
|
||||
padding atomic.Pointer[padding.PaddingFactory]
|
||||
}
|
||||
|
||||
func New(config LC.AnyTLSServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
func New(config LC.AnyTLSServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-ANYTLS"),
|
||||
|
||||
@@ -40,7 +40,7 @@ func (l *Listener) Close() error {
|
||||
}
|
||||
|
||||
func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
return NewWithConfig(LC.AuthServer{Enable: true, Listen: addr, AuthStore: authStore.Default}, inbound.NewListenerConfig(), tunnel, additions...)
|
||||
return NewWithConfig(LC.AuthServer{Enable: true, Listen: addr, AuthStore: authStore.Default}, inbound.NewListenConfig(), tunnel, additions...)
|
||||
}
|
||||
|
||||
// NewWithAuthenticate
|
||||
@@ -50,10 +50,10 @@ func NewWithAuthenticate(addr string, tunnel C.Tunnel, authenticate bool, additi
|
||||
if !authenticate {
|
||||
store = authStore.Nil
|
||||
}
|
||||
return NewWithConfig(LC.AuthServer{Enable: true, Listen: addr, AuthStore: store}, inbound.NewListenerConfig(), tunnel, additions...)
|
||||
return NewWithConfig(LC.AuthServer{Enable: true, Listen: addr, AuthStore: store}, inbound.NewListenConfig(), tunnel, additions...)
|
||||
}
|
||||
|
||||
func NewWithConfig(config LC.AuthServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func NewWithConfig(config LC.AuthServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
isDefault := false
|
||||
if len(additions) == 0 {
|
||||
isDefault = true
|
||||
|
||||
@@ -36,7 +36,7 @@ const (
|
||||
|
||||
func DefaultALPN() []string { return []string{"h2", "http/1.1"} }
|
||||
|
||||
func New(config LC.Hysteria2RealmServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func New(config LC.Hysteria2RealmServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-HYSTERIA2-REALM"),
|
||||
|
||||
@@ -74,7 +74,7 @@ func (v *AnyTLS) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (v *AnyTLS) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
v.l, err = anytls.New(v.vs, v.ListenerConfig(), tunnel, v.Additions()...)
|
||||
v.l, err = anytls.New(v.vs, v.ListenConfig(), tunnel, v.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ func (b *Base) Additions() []inbound.Addition {
|
||||
return b.config.Additions()
|
||||
}
|
||||
|
||||
func (b *Base) ListenerConfig() *inbound.ListenerConfig {
|
||||
return b.config.ListenerConfig()
|
||||
func (b *Base) ListenConfig() *inbound.ListenConfig {
|
||||
return b.config.ListenConfig()
|
||||
}
|
||||
|
||||
var _ C.InboundListener = (*Base)(nil)
|
||||
@@ -114,8 +114,8 @@ func (o BaseOption) Additions() []inbound.Addition {
|
||||
}
|
||||
}
|
||||
|
||||
func (o BaseOption) ListenerConfig() *inbound.ListenerConfig {
|
||||
lc := inbound.NewListenerConfig()
|
||||
func (o BaseOption) ListenConfig() *inbound.ListenConfig {
|
||||
lc := inbound.NewListenConfig()
|
||||
lc.SetRouteMark(o.RoutingMark)
|
||||
return lc
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func (h *HTTP) Address() string {
|
||||
|
||||
// Listen implements constant.InboundListener
|
||||
func (h *HTTP) Listen(tunnel C.Tunnel) error {
|
||||
lc := h.ListenerConfig()
|
||||
lc := h.ListenConfig()
|
||||
for _, addr := range strings.Split(h.RawAddress(), ",") {
|
||||
l, err := http.NewWithConfig(
|
||||
LC.AuthServer{
|
||||
|
||||
@@ -146,7 +146,7 @@ func (t *Hysteria2) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (t *Hysteria2) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
t.l, err = sing_hysteria2.New(t.ts, t.ListenerConfig(), tunnel, t.Additions()...)
|
||||
t.l, err = sing_hysteria2.New(t.ts, t.ListenConfig(), tunnel, t.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (t *Hysteria2RealmServer) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (t *Hysteria2RealmServer) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
t.l, err = hysteria2_realm.New(t.ts, t.ListenerConfig(), tunnel, t.Additions()...)
|
||||
t.l, err = hysteria2_realm.New(t.ts, t.ListenConfig(), tunnel, t.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ func buildMieruServerConfig(option *MieruOption, ports utils.IntRanges[uint16])
|
||||
UserHintIsMandatory: proto.Bool(true),
|
||||
}
|
||||
}
|
||||
lc := option.ListenerConfig()
|
||||
lc := option.ListenConfig()
|
||||
return &mieruserver.ServerConfig{
|
||||
Config: &mierupb.ServerConfig{
|
||||
PortBindings: portBindings,
|
||||
|
||||
@@ -64,7 +64,7 @@ func (m *Mixed) Address() string {
|
||||
|
||||
// Listen implements constant.InboundListener
|
||||
func (m *Mixed) Listen(tunnel C.Tunnel) error {
|
||||
lc := m.ListenerConfig()
|
||||
lc := m.ListenConfig()
|
||||
for _, addr := range strings.Split(m.RawAddress(), ",") {
|
||||
config := LC.AuthServer{
|
||||
Enable: true,
|
||||
|
||||
@@ -84,7 +84,7 @@ func (s *ShadowSocks) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (s *ShadowSocks) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
s.l, err = sing_shadowsocks.New(s.ss, s.ListenerConfig(), tunnel, s.Additions()...)
|
||||
s.l, err = sing_shadowsocks.New(s.ss, s.ListenConfig(), tunnel, s.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func (s *Snell) Address() string {
|
||||
|
||||
func (s *Snell) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
s.l, err = snell.New(s.snell, s.ListenerConfig(), tunnel, s.Additions()...)
|
||||
s.l, err = snell.New(s.snell, s.ListenConfig(), tunnel, s.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func (s *Socks) Address() string {
|
||||
|
||||
// Listen implements constant.InboundListener
|
||||
func (s *Socks) Listen(tunnel C.Tunnel) error {
|
||||
lc := s.ListenerConfig()
|
||||
lc := s.ListenConfig()
|
||||
for _, addr := range strings.Split(s.RawAddress(), ",") {
|
||||
config := LC.AuthServer{
|
||||
Enable: true,
|
||||
|
||||
@@ -114,7 +114,7 @@ func (s *Sudoku) Listen(tunnel C.Tunnel) error {
|
||||
}
|
||||
|
||||
var errs []error
|
||||
lc := s.ListenerConfig()
|
||||
lc := s.ListenConfig()
|
||||
for _, addr := range strings.Split(s.RawAddress(), ",") {
|
||||
conf := s.serverConf
|
||||
conf.Listen = addr
|
||||
|
||||
@@ -105,7 +105,7 @@ func (v *Trojan) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (v *Trojan) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
v.l, err = trojan.New(v.vs, v.ListenerConfig(), tunnel, v.Additions()...)
|
||||
v.l, err = trojan.New(v.vs, v.ListenConfig(), tunnel, v.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (v *TrustTunnel) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (v *TrustTunnel) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
v.l, err = trusttunnel.New(v.vs, v.ListenerConfig(), tunnel, v.Additions()...)
|
||||
v.l, err = trusttunnel.New(v.vs, v.ListenConfig(), tunnel, v.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (t *Tuic) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (t *Tuic) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
t.l, err = tuic.New(t.ts, t.ListenerConfig(), tunnel, t.Additions()...)
|
||||
t.l, err = tuic.New(t.ts, t.ListenConfig(), tunnel, t.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func (t *Tunnel) Address() string {
|
||||
|
||||
// Listen implements constant.InboundListener
|
||||
func (t *Tunnel) Listen(tunnel C.Tunnel) error {
|
||||
lc := t.ListenerConfig()
|
||||
lc := t.ListenConfig()
|
||||
for _, addr := range strings.Split(t.RawAddress(), ",") {
|
||||
for _, network := range t.config.Network {
|
||||
switch network {
|
||||
|
||||
@@ -148,7 +148,7 @@ func (v *Vless) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (v *Vless) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
v.l, err = sing_vless.New(v.vs, v.ListenerConfig(), tunnel, v.Additions()...)
|
||||
v.l, err = sing_vless.New(v.vs, v.ListenConfig(), tunnel, v.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (v *Vmess) Address() string {
|
||||
// Listen implements constant.InboundListener
|
||||
func (v *Vmess) Listen(tunnel C.Tunnel) error {
|
||||
var err error
|
||||
v.l, err = sing_vmess.New(v.vs, v.ListenerConfig(), tunnel, v.Additions()...)
|
||||
v.l, err = sing_vmess.New(v.vs, v.ListenConfig(), tunnel, v.Additions()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ func ReCreateShadowSocks(shadowSocksConfig string, tunnel C.Tunnel) {
|
||||
return
|
||||
}
|
||||
|
||||
listener, err := sing_shadowsocks.New(ssConfig, inbound.NewListenerConfig(), tunnel)
|
||||
listener, err := sing_shadowsocks.New(ssConfig, inbound.NewListenConfig(), tunnel)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -336,7 +336,7 @@ func ReCreateVmess(vmessConfig string, tunnel C.Tunnel) {
|
||||
return
|
||||
}
|
||||
|
||||
listener, err := sing_vmess.New(vsConfig, inbound.NewListenerConfig(), tunnel)
|
||||
listener, err := sing_vmess.New(vsConfig, inbound.NewListenConfig(), tunnel)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -381,7 +381,7 @@ func ReCreateTuic(config LC.TuicServer, tunnel C.Tunnel) {
|
||||
return
|
||||
}
|
||||
|
||||
listener, err := tuic.New(config, inbound.NewListenerConfig(), tunnel)
|
||||
listener, err := tuic.New(config, inbound.NewListenConfig(), tunnel)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -601,7 +601,7 @@ func PatchTunnel(tunnels []LC.Tunnel, tunnel C.Tunnel) {
|
||||
}
|
||||
}
|
||||
|
||||
lc := inbound.NewListenerConfig()
|
||||
lc := inbound.NewListenConfig()
|
||||
for _, elm := range needCreate {
|
||||
key := fmt.Sprintf("%s/%s/%s", elm.addr, elm.target, elm.proxy)
|
||||
if elm.network == "tcp" {
|
||||
|
||||
@@ -46,10 +46,10 @@ func (l *Listener) Close() error {
|
||||
}
|
||||
|
||||
func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
return NewWithConfig(LC.AuthServer{Enable: true, Listen: addr, AuthStore: authStore.Default}, inbound.NewListenerConfig(), tunnel, additions...)
|
||||
return NewWithConfig(LC.AuthServer{Enable: true, Listen: addr, AuthStore: authStore.Default}, inbound.NewListenConfig(), tunnel, additions...)
|
||||
}
|
||||
|
||||
func NewWithConfig(config LC.AuthServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func NewWithConfig(config LC.AuthServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
isDefault := false
|
||||
if len(additions) == 0 {
|
||||
isDefault = true
|
||||
|
||||
@@ -28,7 +28,7 @@ type Listener struct {
|
||||
|
||||
var _listener *Listener
|
||||
|
||||
func New(config LC.ShadowsocksServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func New(config LC.ShadowsocksServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
pickCipher, err := core.PickCipher(config.Cipher, nil, config.Password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -18,7 +18,7 @@ type UDPListener struct {
|
||||
closed bool
|
||||
}
|
||||
|
||||
func NewUDP(addr string, lc *inbound.ListenerConfig, pickCipher core.Cipher, tunnel C.Tunnel, additions ...inbound.Addition) (*UDPListener, error) {
|
||||
func NewUDP(addr string, lc *inbound.ListenConfig, pickCipher core.Cipher, tunnel C.Tunnel, additions ...inbound.Addition) (*UDPListener, error) {
|
||||
l, err := lc.ListenPacket(context.Background(), "udp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -40,7 +40,7 @@ type Listener struct {
|
||||
services []*hysteria2.Service[string]
|
||||
}
|
||||
|
||||
func New(config LC.Hysteria2Server, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func New(config LC.Hysteria2Server, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
var sl *Listener
|
||||
var err error
|
||||
if len(additions) == 0 {
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s *shadowTLSService) NewConnection(ctx context.Context, conn net.Conn, met
|
||||
return s.Service.NewConnection(ctx, conn, metadata)
|
||||
}
|
||||
|
||||
func New(config LC.ShadowsocksServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (C.MultiAddrListener, error) {
|
||||
func New(config LC.ShadowsocksServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (C.MultiAddrListener, error) {
|
||||
var sl *Listener
|
||||
var err error
|
||||
if len(additions) == 0 {
|
||||
|
||||
@@ -35,7 +35,7 @@ type Listener struct {
|
||||
decryption *encryption.ServerInstance
|
||||
}
|
||||
|
||||
func New(config LC.VlessServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
func New(config LC.VlessServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-VLESS"),
|
||||
|
||||
@@ -35,7 +35,7 @@ type Listener struct {
|
||||
|
||||
var _listener *Listener
|
||||
|
||||
func New(config LC.VmessServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
func New(config LC.VmessServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-VMESS"),
|
||||
|
||||
@@ -30,7 +30,7 @@ type Listener struct {
|
||||
listeners []net.Listener
|
||||
}
|
||||
|
||||
func New(config LC.SnellServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (C.MultiAddrListener, error) {
|
||||
func New(config LC.SnellServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (C.MultiAddrListener, error) {
|
||||
if config.Version == 0 {
|
||||
config.Version = snell.Version4
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ func defaultConfig(addr string) LC.AuthServer {
|
||||
}
|
||||
|
||||
func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
return NewWithConfig(defaultConfig(addr), inbound.NewListenerConfig(), tunnel, additions...)
|
||||
return NewWithConfig(defaultConfig(addr), inbound.NewListenConfig(), tunnel, additions...)
|
||||
}
|
||||
|
||||
func NewWithConfig(config LC.AuthServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func NewWithConfig(config LC.AuthServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
isDefault := false
|
||||
if len(additions) == 0 {
|
||||
isDefault = true
|
||||
|
||||
@@ -36,10 +36,10 @@ func (l *UDPListener) Close() error {
|
||||
}
|
||||
|
||||
func NewUDP(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*UDPListener, error) {
|
||||
return NewUDPWithConfig(defaultConfig(addr), inbound.NewListenerConfig(), tunnel, additions...)
|
||||
return NewUDPWithConfig(defaultConfig(addr), inbound.NewListenConfig(), tunnel, additions...)
|
||||
}
|
||||
|
||||
func NewUDPWithConfig(config LC.AuthServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*UDPListener, error) {
|
||||
func NewUDPWithConfig(config LC.AuthServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*UDPListener, error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-SOCKS"),
|
||||
|
||||
@@ -229,7 +229,7 @@ func relayToFallback(wrapper net.Conn, rawConn net.Conn, fallback net.Conn) {
|
||||
N.Relay(rawConn, fallback)
|
||||
}
|
||||
|
||||
func New(config LC.SudokuServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func New(config LC.SudokuServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-SUDOKU"),
|
||||
|
||||
@@ -38,7 +38,7 @@ type Listener struct {
|
||||
handler *sing.ListenerHandler
|
||||
}
|
||||
|
||||
func New(config LC.TrojanServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
func New(config LC.TrojanServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-TROJAN"),
|
||||
|
||||
@@ -29,7 +29,7 @@ type Listener struct {
|
||||
services []*trusttunnel.Service
|
||||
}
|
||||
|
||||
func New(config LC.TrustTunnelServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
func New(config LC.TrustTunnelServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (sl *Listener, err error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-TRUSTTUNNEL"),
|
||||
|
||||
@@ -33,7 +33,7 @@ type Listener struct {
|
||||
servers []*tuic.Server
|
||||
}
|
||||
|
||||
func New(config LC.TuicServer, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func New(config LC.TuicServer, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-TUIC"),
|
||||
|
||||
@@ -38,7 +38,7 @@ func (l *Listener) handleTCP(conn net.Conn, tunnel C.Tunnel, additions ...inboun
|
||||
tunnel.HandleTCPConn(inbound.NewSocket(l.target, conn, C.TUNNEL, additions...))
|
||||
}
|
||||
|
||||
func New(addr, target, proxy string, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
func New(addr, target, proxy string, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
l, err := lc.Listen(context.Background(), "tcp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -35,7 +35,7 @@ func (l *PacketConn) Close() error {
|
||||
return l.conn.Close()
|
||||
}
|
||||
|
||||
func NewUDP(addr, target, proxy string, lc *inbound.ListenerConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*PacketConn, error) {
|
||||
func NewUDP(addr, target, proxy string, lc *inbound.ListenConfig, tunnel C.Tunnel, additions ...inbound.Addition) (*PacketConn, error) {
|
||||
l, err := lc.ListenPacket(context.Background(), "udp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user