Browse Source

v5: Remove v2ctl & wv2ray (rebased from 7c1ab062064c515e8c14669edb7c75173c0e8d2c)

Jebbs 5 years ago
parent
commit
b05a469488
100 changed files with 83 additions and 602 deletions
  1. 0 10
      .github/workflows/release.yml
  2. 0 3
      app/commander/commander.go
  3. 0 3
      app/commander/outbound.go
  4. 0 3
      app/commander/service.go
  5. 0 3
      app/dispatcher/default.go
  6. 0 3
      app/dispatcher/dispatcher.go
  7. 0 3
      app/dispatcher/sniffer.go
  8. 0 3
      app/dispatcher/stats.go
  9. 1 4
      app/dns/dnscommon.go
  10. 0 3
      app/dns/dnscommon_test.go
  11. 0 3
      app/dns/hosts.go
  12. 2 5
      app/dns/nameserver.go
  13. 20 26
      app/dns/nameserver_doh.go
  14. 27 34
      app/dns/nameserver_udp.go
  15. 0 3
      app/log/command/command.go
  16. 0 3
      app/log/log.go
  17. 0 13
      app/log/log_creator.go
  18. 0 3
      app/proxyman/command/command.go
  19. 0 3
      app/reverse/bridge.go
  20. 0 3
      app/reverse/config.go
  21. 1 4
      app/reverse/portal.go
  22. 0 3
      app/reverse/reverse.go
  23. 0 3
      app/router/command/command.go
  24. 0 3
      app/router/condition.go
  25. 1 4
      app/router/condition_geoip.go
  26. 0 3
      app/router/config.go
  27. 0 3
      app/router/router.go
  28. 0 3
      app/stats/channel.go
  29. 0 3
      app/stats/command/command.go
  30. 0 3
      app/stats/counter.go
  31. 0 3
      app/stats/stats.go
  32. 0 43
      commands/all/certchainhash.go
  33. 0 3
      common/net/connection.go
  34. 0 12
      common/platform/ctlcmd/attr_windows.go
  35. 0 50
      common/platform/ctlcmd/ctlcmd.go
  36. 0 9
      common/platform/ctlcmd/errors.generated.go
  37. 0 3
      config.go
  38. 0 3
      context.go
  39. 0 3
      functions.go
  40. 0 96
      infra/conf/v2ray.go
  41. 0 93
      infra/conf/v2ray_test.go
  42. 0 11
      infra/control/main/main.go
  43. 1 1
      main/commands/all/api/api.go
  44. 1 1
      main/commands/all/api/inbounds_add.go
  45. 1 1
      main/commands/all/api/inbounds_remove.go
  46. 1 1
      main/commands/all/api/logger_restart.go
  47. 1 1
      main/commands/all/api/outbounds_add.go
  48. 1 1
      main/commands/all/api/outbounds_remove.go
  49. 1 1
      main/commands/all/api/shared.go
  50. 1 1
      main/commands/all/api/stats_get.go
  51. 1 1
      main/commands/all/api/stats_query.go
  52. 1 1
      main/commands/all/api/stats_sys.go
  53. 3 3
      main/commands/all/commands.go
  54. 1 1
      main/commands/all/convert.go
  55. 1 1
      main/commands/all/convert_confs.go
  56. 0 0
      main/commands/all/errors.generated.go
  57. 1 1
      main/commands/all/format_doc.go
  58. 1 1
      main/commands/all/love.go
  59. 1 1
      main/commands/all/merge_doc.go
  60. 1 1
      main/commands/all/tls/cert.go
  61. 1 1
      main/commands/all/tls/ping.go
  62. 1 1
      main/commands/all/tls/tls.go
  63. 1 1
      main/commands/all/uuid.go
  64. 1 1
      main/commands/all/verify.go
  65. 0 0
      main/commands/base/command.go
  66. 0 0
      main/commands/base/env.go
  67. 0 0
      main/commands/base/execute.go
  68. 0 0
      main/commands/base/help.go
  69. 0 0
      main/commands/base/root.go
  70. 1 1
      main/commands/run.go
  71. 1 1
      main/commands/test.go
  72. 1 1
      main/commands/version.go
  73. 1 1
      main/distro/all/all.go
  74. 1 1
      main/main.go
  75. 0 3
      proxy/blackhole/blackhole.go
  76. 0 3
      proxy/dns/dns.go
  77. 0 3
      proxy/dokodemo/dokodemo.go
  78. 1 4
      proxy/freedom/freedom.go
  79. 0 3
      proxy/http/client.go
  80. 0 3
      proxy/http/server.go
  81. 0 3
      proxy/shadowsocks/client.go
  82. 2 3
      proxy/shadowsocks/protocol.go
  83. 0 3
      proxy/shadowsocks/server.go
  84. 0 3
      proxy/socks/client.go
  85. 0 3
      proxy/socks/config.go
  86. 0 3
      proxy/socks/protocol.go
  87. 0 3
      proxy/socks/server.go
  88. 0 3
      proxy/trojan/client.go
  89. 0 3
      proxy/trojan/server.go
  90. 0 3
      proxy/trojan/validator.go
  91. 0 3
      proxy/vless/encoding/encoding.go
  92. 0 3
      proxy/vless/inbound/config.go
  93. 0 3
      proxy/vless/inbound/inbound.go
  94. 0 3
      proxy/vless/outbound/config.go
  95. 0 3
      proxy/vless/outbound/outbound.go
  96. 0 3
      proxy/vless/validator.go
  97. 0 3
      proxy/vmess/inbound/config.go
  98. 0 3
      proxy/vmess/inbound/inbound.go
  99. 0 3
      proxy/vmess/outbound/command.go
  100. 0 3
      proxy/vmess/outbound/outbound.go

+ 0 - 10
.github/workflows/release.yml

@@ -109,16 +109,6 @@ jobs:
         run: |
           mkdir -p build_assets
           go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main
-          go build -v -o build_assets/v2ctl -trimpath -ldflags "-s -w -buildid=" -tags confonly ./infra/control/main
-
-      - name: Build Windows wv2ray
-        if: matrix.goos == 'windows'
-        run: |
-          echo "::warning ::wv2ray.exe will be removed in v5"
-          go build -v -o build_assets/wv2ray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main
-          cd ./build_assets || exit 1
-          mv v2ray v2ray.exe
-          mv v2ctl v2ctl.exe
 
       - name: Download geo files
         run: |

+ 0 - 3
app/commander/commander.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package commander
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
app/commander/outbound.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package commander
 
 import (

+ 0 - 3
app/commander/service.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package commander
 
 import (

+ 0 - 3
app/dispatcher/default.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dispatcher
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
app/dispatcher/dispatcher.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dispatcher
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
app/dispatcher/sniffer.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dispatcher
 
 import (

+ 0 - 3
app/dispatcher/stats.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dispatcher
 
 import (

+ 1 - 4
app/dns/dnscommon.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dns
 
 import (
@@ -214,7 +211,7 @@ L:
 		case dnsmessage.TypeAAAA:
 			ans, err := parser.AAAAResource()
 			if err != nil {
-				newError("failed to parse AAAA record for domain: ", ah.Name).Base(err).WriteToLog()
+				newError("failed to parse A record for domain: ", ah.Name).Base(err).WriteToLog()
 				break L
 			}
 			ipRecord.IP = append(ipRecord.IP, net.IPAddress(ans.AAAA[:]))

+ 0 - 3
app/dns/dnscommon_test.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dns
 
 import (

+ 0 - 3
app/dns/hosts.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dns
 
 import (

+ 2 - 5
app/dns/nameserver.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dns
 
 import (
@@ -71,7 +68,7 @@ func NewServer(dest net.Destination, dispatcher routing.Dispatcher) (Server, err
 }
 
 // NewClient creates a DNS client managing a name server with client IP, domain rules and expected IPs.
-func NewClient(ctx context.Context, ns *NameServer, clientIP net.IP, container router.GeoIPMatcherContainer, matcherInfos *[]*DomainMatcherInfo, updateDomainRule func(strmatcher.Matcher, int, []*DomainMatcherInfo) error) (*Client, error) {
+func NewClient(ctx context.Context, ns *NameServer, clientIP net.IP, container router.GeoIPMatcherContainer, matcherInfos *[]DomainMatcherInfo, updateDomainRule func(strmatcher.Matcher, int, []DomainMatcherInfo) error) (*Client, error) {
 	client := &Client{}
 
 	err := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error {
@@ -93,7 +90,7 @@ func NewClient(ctx context.Context, ns *NameServer, clientIP net.IP, container r
 			// https://github.com/v2fly/v2ray-core/issues/529
 			// https://github.com/v2fly/v2ray-core/issues/719
 			for i := 0; i < len(localTLDsAndDotlessDomains); i++ {
-				*matcherInfos = append(*matcherInfos, &DomainMatcherInfo{
+				*matcherInfos = append(*matcherInfos, DomainMatcherInfo{
 					clientIdx:     uint16(0),
 					domainRuleIdx: uint16(0),
 				})

+ 20 - 26
app/dns/nameserver_doh.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dns
 
 import (
@@ -33,7 +30,7 @@ import (
 // thus most of the DOH implementation is copied from udpns.go
 type DoHNameServer struct {
 	sync.RWMutex
-	ips        map[string]*record
+	ips        map[string]record
 	pub        *pubsub.Service
 	cleanup    *task.Periodic
 	reqID      uint32
@@ -113,7 +110,7 @@ func NewDoHLocalNameServer(url *url.URL) *DoHNameServer {
 
 func baseDOHNameServer(url *url.URL, prefix string) *DoHNameServer {
 	s := &DoHNameServer{
-		ips:    make(map[string]*record),
+		ips:    make(map[string]record),
 		pub:    pubsub.NewService(),
 		name:   prefix + "//" + url.Host,
 		dohURL: url.String(),
@@ -157,7 +154,7 @@ func (s *DoHNameServer) Cleanup() error {
 	}
 
 	if len(s.ips) == 0 {
-		s.ips = make(map[string]*record)
+		s.ips = make(map[string]record)
 	}
 
 	return nil
@@ -167,10 +164,7 @@ func (s *DoHNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) {
 	elapsed := time.Since(req.start)
 
 	s.Lock()
-	rec, found := s.ips[req.domain]
-	if !found {
-		rec = &record{}
-	}
+	rec := s.ips[req.domain]
 	updated := false
 
 	switch req.reqType {
@@ -180,7 +174,7 @@ func (s *DoHNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) {
 			updated = true
 		}
 	case dnsmessage.TypeAAAA:
-		addr := make([]net.Address, 0, len(ipRec.IP))
+		addr := make([]net.Address, 0)
 		for _, ip := range ipRec.IP {
 			if len(ip.IP()) == net.IPv6len {
 				addr = append(addr, ip)
@@ -299,30 +293,30 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt
 		return nil, errRecordNotFound
 	}
 
-	var err4 error
-	var err6 error
 	var ips []net.Address
-	var ip6 []net.Address
-
-	if option.IPv4Enable {
-		ips, err4 = record.A.getIPs()
+	var lastErr error
+	if option.IPv6Enable && record.AAAA != nil && record.AAAA.RCode == dnsmessage.RCodeSuccess {
+		aaaa, err := record.AAAA.getIPs()
+		if err != nil {
+			lastErr = err
+		}
+		ips = append(ips, aaaa...)
 	}
 
-	if option.IPv6Enable {
-		ip6, err6 = record.AAAA.getIPs()
-		ips = append(ips, ip6...)
+	if option.IPv4Enable && record.A != nil && record.A.RCode == dnsmessage.RCodeSuccess {
+		a, err := record.A.getIPs()
+		if err != nil {
+			lastErr = err
+		}
+		ips = append(ips, a...)
 	}
 
 	if len(ips) > 0 {
 		return toNetIP(ips)
 	}
 
-	if err4 != nil {
-		return nil, err4
-	}
-
-	if err6 != nil {
-		return nil, err6
+	if lastErr != nil {
+		return nil, lastErr
 	}
 
 	if (option.IPv4Enable && record.A != nil) || (option.IPv6Enable && record.AAAA != nil) {

+ 27 - 34
app/dns/nameserver_udp.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dns
 
 import (
@@ -29,9 +26,9 @@ import (
 type ClassicNameServer struct {
 	sync.RWMutex
 	name      string
-	address   *net.Destination
-	ips       map[string]*record
-	requests  map[uint16]*dnsRequest
+	address   net.Destination
+	ips       map[string]record
+	requests  map[uint16]dnsRequest
 	pub       *pubsub.Service
 	udpServer *udp.Dispatcher
 	cleanup   *task.Periodic
@@ -46,9 +43,9 @@ func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher
 	}
 
 	s := &ClassicNameServer{
-		address:  &address,
-		ips:      make(map[string]*record),
-		requests: make(map[uint16]*dnsRequest),
+		address:  address,
+		ips:      make(map[string]record),
+		requests: make(map[uint16]dnsRequest),
 		pub:      pubsub.NewService(),
 		name:     strings.ToUpper(address.String()),
 	}
@@ -85,7 +82,6 @@ func (s *ClassicNameServer) Cleanup() error {
 		}
 
 		if record.A == nil && record.AAAA == nil {
-			newError(s.name, " cleanup ", domain).AtDebug().WriteToLog()
 			delete(s.ips, domain)
 		} else {
 			s.ips[domain] = record
@@ -93,7 +89,7 @@ func (s *ClassicNameServer) Cleanup() error {
 	}
 
 	if len(s.ips) == 0 {
-		s.ips = make(map[string]*record)
+		s.ips = make(map[string]record)
 	}
 
 	for id, req := range s.requests {
@@ -103,7 +99,7 @@ func (s *ClassicNameServer) Cleanup() error {
 	}
 
 	if len(s.requests) == 0 {
-		s.requests = make(map[uint16]*dnsRequest)
+		s.requests = make(map[uint16]dnsRequest)
 	}
 
 	return nil
@@ -141,17 +137,15 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_prot
 	elapsed := time.Since(req.start)
 	newError(s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed).AtInfo().WriteToLog()
 	if len(req.domain) > 0 && (rec.A != nil || rec.AAAA != nil) {
-		s.updateIP(req.domain, &rec)
+		s.updateIP(req.domain, rec)
 	}
 }
 
-func (s *ClassicNameServer) updateIP(domain string, newRec *record) {
+func (s *ClassicNameServer) updateIP(domain string, newRec record) {
 	s.Lock()
 
-	rec, found := s.ips[domain]
-	if !found {
-		rec = &record{}
-	}
+	newError(s.name, " updating IP records for domain:", domain).AtDebug().WriteToLog()
+	rec := s.ips[domain]
 
 	updated := false
 	if isNewer(rec.A, newRec.A) {
@@ -164,7 +158,6 @@ func (s *ClassicNameServer) updateIP(domain string, newRec *record) {
 	}
 
 	if updated {
-		newError(s.name, " updating IP records for domain:", domain).AtDebug().WriteToLog()
 		s.ips[domain] = rec
 	}
 	if newRec.A != nil {
@@ -187,7 +180,7 @@ func (s *ClassicNameServer) addPendingRequest(req *dnsRequest) {
 
 	id := req.msg.ID
 	req.expire = time.Now().Add(time.Second * 8)
-	s.requests[id] = req
+	s.requests[id] = *req
 }
 
 func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) {
@@ -205,7 +198,7 @@ func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, client
 		udpCtx = session.ContextWithContent(udpCtx, &session.Content{
 			Protocol: "dns",
 		})
-		s.udpServer.Dispatch(udpCtx, *s.address, b)
+		s.udpServer.Dispatch(udpCtx, s.address, b)
 	}
 }
 
@@ -218,30 +211,30 @@ func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.I
 		return nil, errRecordNotFound
 	}
 
-	var err4 error
-	var err6 error
 	var ips []net.Address
-	var ip6 []net.Address
-
+	var lastErr error
 	if option.IPv4Enable {
-		ips, err4 = record.A.getIPs()
+		a, err := record.A.getIPs()
+		if err != nil {
+			lastErr = err
+		}
+		ips = append(ips, a...)
 	}
 
 	if option.IPv6Enable {
-		ip6, err6 = record.AAAA.getIPs()
-		ips = append(ips, ip6...)
+		aaaa, err := record.AAAA.getIPs()
+		if err != nil {
+			lastErr = err
+		}
+		ips = append(ips, aaaa...)
 	}
 
 	if len(ips) > 0 {
 		return toNetIP(ips)
 	}
 
-	if err4 != nil {
-		return nil, err4
-	}
-
-	if err6 != nil {
-		return nil, err6
+	if lastErr != nil {
+		return nil, lastErr
 	}
 
 	return nil, dns_feature.ErrEmptyResponse

+ 0 - 3
app/log/command/command.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package command
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
app/log/log.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package log
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 13
app/log/log_creator.go

@@ -1,11 +1,6 @@
-//go:build !confonly
-// +build !confonly
-
 package log
 
 import (
-	"sync"
-
 	"github.com/v2fly/v2ray-core/v4/common"
 	"github.com/v2fly/v2ray-core/v4/common/log"
 )
@@ -18,24 +13,16 @@ type HandlerCreator func(LogType, HandlerCreatorOptions) (log.Handler, error)
 
 var handlerCreatorMap = make(map[LogType]HandlerCreator)
 
-var handlerCreatorMapLock = &sync.RWMutex{}
-
 func RegisterHandlerCreator(logType LogType, f HandlerCreator) error {
 	if f == nil {
 		return newError("nil HandlerCreator")
 	}
 
-	handlerCreatorMapLock.Lock()
-	defer handlerCreatorMapLock.Unlock()
-
 	handlerCreatorMap[logType] = f
 	return nil
 }
 
 func createHandler(logType LogType, options HandlerCreatorOptions) (log.Handler, error) {
-	handlerCreatorMapLock.RLock()
-	defer handlerCreatorMapLock.RUnlock()
-
 	creator, found := handlerCreatorMap[logType]
 	if !found {
 		return nil, newError("unable to create log handler for ", logType)

+ 0 - 3
app/proxyman/command/command.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package command
 
 import (

+ 0 - 3
app/reverse/bridge.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package reverse
 
 import (

+ 0 - 3
app/reverse/config.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package reverse
 
 import (

+ 1 - 4
app/reverse/portal.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package reverse
 
 import (
@@ -155,7 +152,7 @@ func (p *StaticMuxPicker) PickAvailable() (*mux.ClientWorker, error) {
 		return nil, newError("empty worker list")
 	}
 
-	minIdx := -1
+	var minIdx = -1
 	var minConn uint32 = 9999
 	for i, w := range p.workers {
 		if w.draining {

+ 0 - 3
app/reverse/reverse.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package reverse
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
app/router/command/command.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package command
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
app/router/condition.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package router
 
 import (

+ 1 - 4
app/router/condition_geoip.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package router
 
 import (
@@ -62,7 +59,7 @@ func (m *GeoIPMatcher) Init(cidrs []*CIDR) error {
 	m.ip6 = make([]ipv6, 0, ip6Count)
 	m.prefix6 = make([]uint8, 0, ip6Count)
 
-	for _, cidr := range cidrList {
+	for _, cidr := range cidrs {
 		ip := cidr.Ip
 		prefix := uint8(cidr.Prefix)
 		switch len(ip) {

+ 0 - 3
app/router/config.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package router
 
 import (

+ 0 - 3
app/router/router.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package router
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
app/stats/channel.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package stats
 
 import (

+ 0 - 3
app/stats/command/command.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package command
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
app/stats/counter.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package stats
 
 import "sync/atomic"

+ 0 - 3
app/stats/stats.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package stats
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 43
commands/all/certchainhash.go

@@ -1,43 +0,0 @@
-package all
-
-import (
-	"flag"
-	"fmt"
-	"io/ioutil"
-
-	"github.com/v2fly/v2ray-core/v4/commands/base"
-	v2tls "github.com/v2fly/v2ray-core/v4/transport/internet/tls"
-)
-
-type CertificateChainHashCommand struct{}
-
-func (c CertificateChainHashCommand) Name() string {
-	return "certChainHash"
-}
-
-func (c CertificateChainHashCommand) Description() base.Command {
-	return base.Command{
-		Short:     "Calculate TLS certificates hash.",
-		UsageLine: "v2ctl certChainHash --cert <cert.pem Calculate TLS certificate chain hash.",
-	}
-}
-
-func (c CertificateChainHashCommand) Execute(args []string) error {
-	fs := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
-	cert := fs.String("cert", "fullchain.pem", "The file path of the certificates chain")
-	if err := fs.Parse(args); err != nil {
-		return err
-	}
-	certContent, err := ioutil.ReadFile(*cert)
-	if err != nil {
-		return err
-	}
-	certChainHashB64 := v2tls.CalculatePEMCertChainSHA256Hash(certContent)
-	fmt.Println(certChainHashB64)
-	return nil
-}
-
-func init() {
-	// Do not release tool before v5's refactor
-	// common.Must(RegisterCommand(&CertificateChainHashCommand{}))
-}

+ 0 - 3
common/net/connection.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package net
 
 import (

+ 0 - 12
common/platform/ctlcmd/attr_windows.go

@@ -1,12 +0,0 @@
-//go:build windows
-// +build windows
-
-package ctlcmd
-
-import "syscall"
-
-func getSysProcAttr() *syscall.SysProcAttr {
-	return &syscall.SysProcAttr{
-		HideWindow: true,
-	}
-}

+ 0 - 50
common/platform/ctlcmd/ctlcmd.go

@@ -1,50 +0,0 @@
-package ctlcmd
-
-import (
-	"io"
-	"os"
-	"os/exec"
-	"strings"
-
-	"github.com/v2fly/v2ray-core/v4/common/buf"
-	"github.com/v2fly/v2ray-core/v4/common/platform"
-)
-
-//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
-
-func Run(args []string, input io.Reader) (buf.MultiBuffer, error) {
-	v2ctl := platform.GetToolLocation("v2ctl")
-	if _, err := os.Stat(v2ctl); err != nil {
-		return nil, newError("v2ctl doesn't exist").Base(err)
-	}
-
-	var errBuffer buf.MultiBufferContainer
-	var outBuffer buf.MultiBufferContainer
-
-	cmd := exec.Command(v2ctl, args...)
-	cmd.Stderr = &errBuffer
-	cmd.Stdout = &outBuffer
-	cmd.SysProcAttr = getSysProcAttr()
-	if input != nil {
-		cmd.Stdin = input
-	}
-
-	if err := cmd.Start(); err != nil {
-		return nil, newError("failed to start v2ctl").Base(err)
-	}
-
-	if err := cmd.Wait(); err != nil {
-		msg := "failed to execute v2ctl"
-		if errBuffer.Len() > 0 {
-			msg += ": \n" + strings.TrimSpace(errBuffer.MultiBuffer.String())
-		}
-		return nil, newError(msg).Base(err)
-	}
-
-	// log stderr, info message
-	if !errBuffer.IsEmpty() {
-		newError("<v2ctl message> \n", strings.TrimSpace(errBuffer.MultiBuffer.String())).AtInfo().WriteToLog()
-	}
-
-	return outBuffer.MultiBuffer, nil
-}

+ 0 - 9
common/platform/ctlcmd/errors.generated.go

@@ -1,9 +0,0 @@
-package ctlcmd
-
-import "github.com/v2fly/v2ray-core/v4/common/errors"
-
-type errPathObjHolder struct{}
-
-func newError(values ...interface{}) *errors.Error {
-	return errors.New(values...).WithPathObj(errPathObjHolder{})
-}

+ 0 - 3
config.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package core
 
 import (

+ 0 - 3
context.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package core
 
 import (

+ 0 - 3
functions.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package core
 
 import (

+ 0 - 96
infra/conf/v2ray.go

@@ -2,8 +2,6 @@ package conf
 
 import (
 	"encoding/json"
-	"log"
-	"os"
 	"strings"
 
 	core "github.com/v2fly/v2ray-core/v4"
@@ -37,8 +35,6 @@ var (
 		"dns":         func() interface{} { return new(DNSOutboundConfig) },
 		"loopback":    func() interface{} { return new(LoopbackConfig) },
 	}, "protocol", "settings")
-
-	ctllog = log.New(os.Stderr, "v2ctl> ", 0)
 )
 
 func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) {
@@ -381,98 +377,6 @@ func (c *Config) findOutboundTag(tag string) int {
 	return found
 }
 
-// Override method accepts another Config overrides the current attribute
-func (c *Config) Override(o *Config, fn string) {
-	// only process the non-deprecated members
-
-	if o.LogConfig != nil {
-		c.LogConfig = o.LogConfig
-	}
-	if o.RouterConfig != nil {
-		c.RouterConfig = o.RouterConfig
-	}
-	if o.DNSConfig != nil {
-		c.DNSConfig = o.DNSConfig
-	}
-	if o.Transport != nil {
-		c.Transport = o.Transport
-	}
-	if o.Policy != nil {
-		c.Policy = o.Policy
-	}
-	if o.API != nil {
-		c.API = o.API
-	}
-	if o.Stats != nil {
-		c.Stats = o.Stats
-	}
-	if o.Reverse != nil {
-		c.Reverse = o.Reverse
-	}
-
-	if o.FakeDNS != nil {
-		c.FakeDNS = o.FakeDNS
-	}
-
-	if o.BrowserForwarder != nil {
-		c.BrowserForwarder = o.BrowserForwarder
-	}
-
-	if o.Observatory != nil {
-		c.Observatory = o.Observatory
-	}
-
-	// deprecated attrs... keep them for now
-	if o.InboundConfig != nil {
-		c.InboundConfig = o.InboundConfig
-	}
-	if o.OutboundConfig != nil {
-		c.OutboundConfig = o.OutboundConfig
-	}
-	if o.InboundDetours != nil {
-		c.InboundDetours = o.InboundDetours
-	}
-	if o.OutboundDetours != nil {
-		c.OutboundDetours = o.OutboundDetours
-	}
-	// deprecated attrs
-
-	// update the Inbound in slice if the only one in overide config has same tag
-	if len(o.InboundConfigs) > 0 {
-		if len(c.InboundConfigs) > 0 && len(o.InboundConfigs) == 1 {
-			if idx := c.findInboundTag(o.InboundConfigs[0].Tag); idx > -1 {
-				c.InboundConfigs[idx] = o.InboundConfigs[0]
-				ctllog.Println("[", fn, "] updated inbound with tag: ", o.InboundConfigs[0].Tag)
-			} else {
-				c.InboundConfigs = append(c.InboundConfigs, o.InboundConfigs[0])
-				ctllog.Println("[", fn, "] appended inbound with tag: ", o.InboundConfigs[0].Tag)
-			}
-		} else {
-			c.InboundConfigs = o.InboundConfigs
-		}
-	}
-
-	// update the Outbound in slice if the only one in overide config has same tag
-	if len(o.OutboundConfigs) > 0 {
-		if len(c.OutboundConfigs) > 0 && len(o.OutboundConfigs) == 1 {
-			if idx := c.findOutboundTag(o.OutboundConfigs[0].Tag); idx > -1 {
-				c.OutboundConfigs[idx] = o.OutboundConfigs[0]
-				ctllog.Println("[", fn, "] updated outbound with tag: ", o.OutboundConfigs[0].Tag)
-			} else {
-				if strings.Contains(strings.ToLower(fn), "tail") {
-					c.OutboundConfigs = append(c.OutboundConfigs, o.OutboundConfigs[0])
-					ctllog.Println("[", fn, "] appended outbound with tag: ", o.OutboundConfigs[0].Tag)
-				} else {
-					c.OutboundConfigs = append(o.OutboundConfigs, c.OutboundConfigs...)
-					ctllog.Println("[", fn, "] prepended outbound with tag: ", o.OutboundConfigs[0].Tag)
-				}
-			}
-		} else {
-			c.OutboundConfigs = o.OutboundConfigs
-		}
-	}
-}
-
 func applyTransportConfig(s *StreamConfig, t *TransportConfig) {
 	if s.TCPSettings == nil {
 		s.TCPSettings = t.TCPConfig

+ 0 - 93
infra/conf/v2ray_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/golang/protobuf/proto"
-	"github.com/google/go-cmp/cmp"
 
 	core "github.com/v2fly/v2ray-core/v4"
 	"github.com/v2fly/v2ray-core/v4/app/dispatcher"
@@ -371,95 +370,3 @@ func TestMuxConfig_Build(t *testing.T) {
 		})
 	}
 }
-
-func TestConfig_Override(t *testing.T) {
-	tests := []struct {
-		name string
-		orig *Config
-		over *Config
-		fn   string
-		want *Config
-	}{
-		{
-			"combine/empty",
-			&Config{},
-			&Config{
-				LogConfig:    &LogConfig{},
-				RouterConfig: &RouterConfig{},
-				DNSConfig:    &DNSConfig{},
-				Transport:    &TransportConfig{},
-				Policy:       &PolicyConfig{},
-				API:          &APIConfig{},
-				Stats:        &StatsConfig{},
-				Reverse:      &ReverseConfig{},
-			},
-			"",
-			&Config{
-				LogConfig:    &LogConfig{},
-				RouterConfig: &RouterConfig{},
-				DNSConfig:    &DNSConfig{},
-				Transport:    &TransportConfig{},
-				Policy:       &PolicyConfig{},
-				API:          &APIConfig{},
-				Stats:        &StatsConfig{},
-				Reverse:      &ReverseConfig{},
-			},
-		},
-		{
-			"combine/newattr",
-			&Config{InboundConfigs: []InboundDetourConfig{{Tag: "old"}}},
-			&Config{LogConfig: &LogConfig{}}, "",
-			&Config{LogConfig: &LogConfig{}, InboundConfigs: []InboundDetourConfig{{Tag: "old"}}},
-		},
-		{
-			"replace/inbounds",
-			&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
-			&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}}},
-			"",
-			&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos0"}, {Tag: "pos1", Protocol: "kcp"}}},
-		},
-		{
-			"replace/inbounds-replaceall",
-			&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
-			&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}},
-			"",
-			&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}},
-		},
-		{
-			"replace/notag-append",
-			&Config{InboundConfigs: []InboundDetourConfig{{}, {Protocol: "vmess"}}},
-			&Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}}},
-			"",
-			&Config{InboundConfigs: []InboundDetourConfig{{}, {Protocol: "vmess"}, {Tag: "pos1", Protocol: "kcp"}}},
-		},
-		{
-			"replace/outbounds",
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}}},
-			"",
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Tag: "pos1", Protocol: "kcp"}}},
-		},
-		{
-			"replace/outbounds-prepend",
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}},
-			"config.json",
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}},
-		},
-		{
-			"replace/outbounds-append",
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}},
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos2", Protocol: "kcp"}}},
-			"config_tail.json",
-			&Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}, {Tag: "pos2", Protocol: "kcp"}}},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			tt.orig.Override(tt.over, tt.fn)
-			if r := cmp.Diff(tt.orig, tt.want); r != "" {
-				t.Error(r)
-			}
-		})
-	}
-}

+ 0 - 11
infra/control/main/main.go

@@ -1,11 +0,0 @@
-package main
-
-import (
-	_ "github.com/v2fly/v2ray-core/v4/commands/all"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
-)
-
-func main() {
-	base.RootCommand.Long = "A tool set for V2Ray."
-	base.Execute()
-}

+ 1 - 1
commands/all/api/api.go → main/commands/all/api/api.go

@@ -1,7 +1,7 @@
 package api
 
 import (
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 // CmdAPI calls an API in an V2Ray process

+ 1 - 1
commands/all/api/inbounds_add.go → main/commands/all/api/inbounds_add.go

@@ -4,10 +4,10 @@ import (
 	"fmt"
 
 	handlerService "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common/cmdarg"
 	"github.com/v2fly/v2ray-core/v4/infra/conf"
 	"github.com/v2fly/v2ray-core/v4/infra/conf/serial"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdAddInbounds = &base.Command{

+ 1 - 1
commands/all/api/inbounds_remove.go → main/commands/all/api/inbounds_remove.go

@@ -4,9 +4,9 @@ import (
 	"fmt"
 
 	handlerService "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common/cmdarg"
 	"github.com/v2fly/v2ray-core/v4/infra/conf/serial"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdRemoveInbounds = &base.Command{

+ 1 - 1
commands/all/api/logger_restart.go → main/commands/all/api/logger_restart.go

@@ -2,7 +2,7 @@ package api
 
 import (
 	logService "github.com/v2fly/v2ray-core/v4/app/log/command"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdRestartLogger = &base.Command{

+ 1 - 1
commands/all/api/outbounds_add.go → main/commands/all/api/outbounds_add.go

@@ -4,10 +4,10 @@ import (
 	"fmt"
 
 	handlerService "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common/cmdarg"
 	"github.com/v2fly/v2ray-core/v4/infra/conf"
 	"github.com/v2fly/v2ray-core/v4/infra/conf/serial"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdAddOutbounds = &base.Command{

+ 1 - 1
commands/all/api/outbounds_remove.go → main/commands/all/api/outbounds_remove.go

@@ -4,9 +4,9 @@ import (
 	"fmt"
 
 	handlerService "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common/cmdarg"
 	"github.com/v2fly/v2ray-core/v4/infra/conf/serial"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdRemoveOutbounds = &base.Command{

+ 1 - 1
commands/all/api/shared.go → main/commands/all/api/shared.go

@@ -6,7 +6,7 @@ import (
 	"strings"
 	"time"
 
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 	"google.golang.org/grpc"
 	"google.golang.org/protobuf/proto"
 )

+ 1 - 1
commands/all/api/stats_get.go → main/commands/all/api/stats_get.go

@@ -2,7 +2,7 @@ package api
 
 import (
 	statsService "github.com/v2fly/v2ray-core/v4/app/stats/command"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdGetStats = &base.Command{

+ 1 - 1
commands/all/api/stats_query.go → main/commands/all/api/stats_query.go

@@ -2,7 +2,7 @@ package api
 
 import (
 	statsService "github.com/v2fly/v2ray-core/v4/app/stats/command"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdQueryStats = &base.Command{

+ 1 - 1
commands/all/api/stats_sys.go → main/commands/all/api/stats_sys.go

@@ -2,7 +2,7 @@ package api
 
 import (
 	statsService "github.com/v2fly/v2ray-core/v4/app/stats/command"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdSysStats = &base.Command{

+ 3 - 3
commands/all/commands.go → main/commands/all/commands.go

@@ -1,9 +1,9 @@
 package all
 
 import (
-	"github.com/v2fly/v2ray-core/v4/commands/all/api"
-	"github.com/v2fly/v2ray-core/v4/commands/all/tls"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/all/api"
+	"github.com/v2fly/v2ray-core/v4/main/commands/all/tls"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 // go:generate go run v2ray.com/core/common/errors/errorgen

+ 1 - 1
commands/all/convert.go → main/commands/all/convert.go

@@ -7,8 +7,8 @@ import (
 	"os"
 	"strings"
 
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/infra/conf/serial"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 	"gopkg.in/yaml.v2"
 )
 

+ 1 - 1
commands/all/convert_confs.go → main/commands/all/convert_confs.go

@@ -6,10 +6,10 @@ import (
 	"path/filepath"
 	"strings"
 
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common/cmdarg"
 	"github.com/v2fly/v2ray-core/v4/infra/conf/json"
 	"github.com/v2fly/v2ray-core/v4/infra/conf/merge"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 func mergeConvertToMap(files []string, format string) map[string]interface{} {

+ 0 - 0
commands/all/errors.generated.go → main/commands/all/errors.generated.go


+ 1 - 1
commands/all/format_doc.go → main/commands/all/format_doc.go

@@ -1,7 +1,7 @@
 package all
 
 import (
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var docFormat = &base.Command{

+ 1 - 1
commands/all/love.go → main/commands/all/love.go

@@ -7,9 +7,9 @@ import (
 	"encoding/base64"
 	"fmt"
 
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common"
 	"github.com/v2fly/v2ray-core/v4/common/platform"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdLove = &base.Command{

+ 1 - 1
commands/all/merge_doc.go → main/commands/all/merge_doc.go

@@ -1,7 +1,7 @@
 package all
 
 import (
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var docMerge = &base.Command{

+ 1 - 1
commands/all/tls/cert.go → main/commands/all/tls/cert.go

@@ -8,10 +8,10 @@ import (
 	"strings"
 	"time"
 
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common"
 	"github.com/v2fly/v2ray-core/v4/common/protocol/tls/cert"
 	"github.com/v2fly/v2ray-core/v4/common/task"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 // cmdCert is the tls cert command

+ 1 - 1
commands/all/tls/ping.go → main/commands/all/tls/ping.go

@@ -7,7 +7,7 @@ import (
 	"fmt"
 	"net"
 
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 	v2tls "github.com/v2fly/v2ray-core/v4/transport/internet/tls"
 )
 

+ 1 - 1
commands/all/tls/tls.go → main/commands/all/tls/tls.go

@@ -1,7 +1,7 @@
 package tls
 
 import (
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 // CmdTLS holds all tls sub commands

+ 1 - 1
commands/all/uuid.go → main/commands/all/uuid.go

@@ -3,8 +3,8 @@ package all
 import (
 	"fmt"
 
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common/uuid"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdUUID = &base.Command{

+ 1 - 1
commands/all/verify.go → main/commands/all/verify.go

@@ -4,7 +4,7 @@ import (
 	"os"
 
 	"github.com/v2fly/VSign/signerVerify"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 var cmdVerify = &base.Command{

+ 0 - 0
commands/base/command.go → main/commands/base/command.go


+ 0 - 0
commands/base/env.go → main/commands/base/env.go


+ 0 - 0
commands/base/execute.go → main/commands/base/execute.go


+ 0 - 0
commands/base/help.go → main/commands/base/help.go


+ 0 - 0
commands/base/root.go → main/commands/base/root.go


+ 1 - 1
main/commands/run.go

@@ -11,9 +11,9 @@ import (
 	"syscall"
 
 	"github.com/v2fly/v2ray-core/v4"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/common/cmdarg"
 	"github.com/v2fly/v2ray-core/v4/common/platform"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 // CmdRun runs V2Ray with config

+ 1 - 1
main/commands/test.go

@@ -5,7 +5,7 @@ import (
 	"log"
 
 	"github.com/v2fly/v2ray-core/v4"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 // CmdTest tests config files

+ 1 - 1
main/commands/version.go

@@ -4,7 +4,7 @@ import (
 	"fmt"
 
 	"github.com/v2fly/v2ray-core/v4"
-	"github.com/v2fly/v2ray-core/v4/commands/base"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 )
 
 // CmdVersion prints V2Ray Versions

+ 1 - 1
main/distro/all/all.go

@@ -80,5 +80,5 @@ import (
 	_ "github.com/v2fly/v2ray-core/v4/main/yaml"
 
 	// commands
-	_ "github.com/v2fly/v2ray-core/v4/commands/all"
+	_ "github.com/v2fly/v2ray-core/v4/main/commands/all"
 )

+ 1 - 1
main/main.go

@@ -1,8 +1,8 @@
 package main
 
 import (
-	"github.com/v2fly/v2ray-core/v4/commands/base"
 	"github.com/v2fly/v2ray-core/v4/main/commands"
+	"github.com/v2fly/v2ray-core/v4/main/commands/base"
 	_ "github.com/v2fly/v2ray-core/v4/main/distro/all"
 )
 

+ 0 - 3
proxy/blackhole/blackhole.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 // Package blackhole is an outbound handler that blocks all connections.
 package blackhole
 

+ 0 - 3
proxy/dns/dns.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dns
 
 import (

+ 0 - 3
proxy/dokodemo/dokodemo.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package dokodemo
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 1 - 4
proxy/freedom/freedom.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package freedom
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen
@@ -67,7 +64,7 @@ func (h *Handler) resolveIP(ctx context.Context, domain string, localAddr net.Ad
 		newError("DNS client doesn't implement ClientWithIPOption")
 	}
 
-	lookupFunc := h.dns.LookupIP
+	var lookupFunc = h.dns.LookupIP
 	if h.config.DomainStrategy == Config_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()) {
 		if lookupIPv4, ok := h.dns.(dns.IPv4Lookup); ok {
 			lookupFunc = lookupIPv4.LookupIPv4

+ 0 - 3
proxy/http/client.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package http
 
 import (

+ 0 - 3
proxy/http/server.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package http
 
 import (

+ 0 - 3
proxy/shadowsocks/client.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package shadowsocks
 
 import (

+ 2 - 3
proxy/shadowsocks/protocol.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package shadowsocks
 
 import (
@@ -40,6 +37,7 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
 	behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
 
 	drainer, err := drain.NewBehaviorSeedLimitedDrainer(int64(behaviorSeed), 16+38, 3266, 64)
+
 	if err != nil {
 		return nil, nil, newError("failed to initialize drainer").Base(err)
 	}
@@ -140,6 +138,7 @@ func ReadTCPResponse(user *protocol.MemoryUser, reader io.Reader) (buf.Reader, e
 	behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
 
 	drainer, err := drain.NewBehaviorSeedLimitedDrainer(int64(behaviorSeed), 16+38, 3266, 64)
+
 	if err != nil {
 		return nil, newError("failed to initialize drainer").Base(err)
 	}

+ 0 - 3
proxy/shadowsocks/server.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package shadowsocks
 
 import (

+ 0 - 3
proxy/socks/client.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package socks
 
 import (

+ 0 - 3
proxy/socks/config.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package socks
 
 import "github.com/v2fly/v2ray-core/v4/common/protocol"

+ 0 - 3
proxy/socks/protocol.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package socks
 
 import (

+ 0 - 3
proxy/socks/server.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package socks
 
 import (

+ 0 - 3
proxy/trojan/client.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package trojan
 
 import (

+ 0 - 3
proxy/trojan/server.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package trojan
 
 import (

+ 0 - 3
proxy/trojan/validator.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package trojan
 
 import (

+ 0 - 3
proxy/vless/encoding/encoding.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package encoding
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
proxy/vless/inbound/config.go

@@ -1,4 +1 @@
-//go:build !confonly
-// +build !confonly
-
 package inbound

+ 0 - 3
proxy/vless/inbound/inbound.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package inbound
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
proxy/vless/outbound/config.go

@@ -1,4 +1 @@
-//go:build !confonly
-// +build !confonly
-
 package outbound

+ 0 - 3
proxy/vless/outbound/outbound.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package outbound
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
proxy/vless/validator.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package vless
 
 import (

+ 0 - 3
proxy/vmess/inbound/config.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package inbound
 
 // GetDefaultValue returns default settings of DefaultConfig.

+ 0 - 3
proxy/vmess/inbound/inbound.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package inbound
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

+ 0 - 3
proxy/vmess/outbound/command.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package outbound
 
 import (

+ 0 - 3
proxy/vmess/outbound/outbound.go

@@ -1,6 +1,3 @@
-//go:build !confonly
-// +build !confonly
-
 package outbound
 
 //go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen

Some files were not shown because too many files changed in this diff