Skip to content

Commit 3b02c02

Browse files
committed
Revert "move init func to separate files"
This reverts commit 3de50a6.
1 parent 2540797 commit 3b02c02

File tree

12 files changed

+49
-74
lines changed

12 files changed

+49
-74
lines changed

app/commander/commander.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,9 @@ func (c *Commander) Close() error {
100100

101101
return nil
102102
}
103+
104+
func init() {
105+
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, cfg interface{}) (interface{}, error) {
106+
return NewCommander(ctx, cfg.(*Config))
107+
}))
108+
}

app/commander/init.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/dns/init.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/dns/server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,9 @@ func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, err
220220

221221
return nil, newError("returning nil for domain ", domain).Base(lastErr)
222222
}
223+
224+
func init() {
225+
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
226+
return New(ctx, config.(*Config))
227+
}))
228+
}

transport/internet/kcp/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package kcp
33
import (
44
"crypto/cipher"
55

6+
"v2ray.com/core/common"
67
"v2ray.com/core/transport/internet"
78
)
89

@@ -96,3 +97,9 @@ func (c *Config) GetReceivingInFlightSize() uint32 {
9697
func (c *Config) GetReceivingBufferSize() uint32 {
9798
return c.GetReadBufferSize() / c.GetMTUValue()
9899
}
100+
101+
func init() {
102+
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
103+
return new(Config)
104+
}))
105+
}

transport/internet/kcp/dialer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"sync/atomic"
88

9+
"v2ray.com/core/common"
910
"v2ray.com/core/common/buf"
1011
"v2ray.com/core/common/dice"
1112
"v2ray.com/core/common/net"
@@ -91,3 +92,7 @@ func DialKCP(ctx context.Context, dest net.Destination, streamSettings *internet
9192

9293
return iConn, nil
9394
}
95+
96+
func init() {
97+
common.Must(internet.RegisterTransportDialer(protocolName, DialKCP))
98+
}

transport/internet/kcp/init.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

transport/internet/kcp/listener.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"crypto/tls"
77
"sync"
88

9+
"v2ray.com/core/common"
910
"v2ray.com/core/common/buf"
1011
"v2ray.com/core/common/net"
1112
"v2ray.com/core/transport/internet"
@@ -189,3 +190,7 @@ func (w *Writer) Close() error {
189190
func ListenKCP(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (internet.Listener, error) {
190191
return NewListener(ctx, address, port, streamSettings, addConn)
191192
}
193+
194+
func init() {
195+
common.Must(internet.RegisterTransportListener(protocolName, ListenKCP))
196+
}

transport/internet/quic/dialer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
210210

211211
return client.openConnection(destAddr, config, tlsConfig, streamSettings.SocketSettings)
212212
}
213+
214+
func init() {
215+
common.Must(internet.RegisterTransportDialer(protocolName, Dial))
216+
}

transport/internet/quic/hub.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"time"
66

7+
"v2ray.com/core/common"
78
"v2ray.com/core/common/net"
89
"v2ray.com/core/common/protocol/tls/cert"
910
"v2ray.com/core/common/signal/done"
@@ -130,3 +131,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
130131

131132
return listener, nil
132133
}
134+
135+
func init() {
136+
common.Must(internet.RegisterTransportListener(protocolName, Listen))
137+
}

transport/internet/quic/init.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

transport/internet/quic/quic.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package quic
22

3+
import (
4+
"v2ray.com/core/common"
5+
"v2ray.com/core/transport/internet"
6+
)
7+
38
//go:generate errorgen
49

510
// Here is some modification needs to be done before update quic vendor.
@@ -10,3 +15,9 @@ package quic
1015

1116
const protocolName = "quic"
1217
const internalDomain = "quic.internal.v2ray.com"
18+
19+
func init() {
20+
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
21+
return new(Config)
22+
}))
23+
}

0 commit comments

Comments
 (0)