Ver código fonte

refactor code

V2Ray 10 anos atrás
pai
commit
a8d07ce931
2 arquivos alterados com 13 adições e 13 exclusões
  1. 11 11
      app/point/point.go
  2. 2 2
      proxy/blackhole/blackhole.go

+ 11 - 11
app/point/point.go

@@ -101,25 +101,25 @@ func NewPoint(pConfig config.PointConfig) (*Point, error) {
 
 // Start starts the Point server, and return any error during the process.
 // In the case of any errors, the state of the server is unpredicatable.
-func (vp *Point) Start() error {
-	if vp.port <= 0 {
-		log.Error("Invalid port %d", vp.port)
+func (this *Point) Start() error {
+	if this.port <= 0 {
+		log.Error("Invalid port %d", this.port)
 		return config.BadConfiguration
 	}
 
 	err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
-		err := vp.ich.Listen(vp.port)
+		err := this.ich.Listen(this.port)
 		if err != nil {
 			return err
 		}
-		log.Warning("Point server started on port %d", vp.port)
+		log.Warning("Point server started on port %d", this.port)
 		return nil
 	})
 	if err != nil {
 		return err
 	}
 
-	for _, detourHandler := range vp.idh {
+	for _, detourHandler := range this.idh {
 		err := detourHandler.Start()
 		if err != nil {
 			return err
@@ -129,14 +129,14 @@ func (vp *Point) Start() error {
 	return nil
 }
 
-func (p *Point) DispatchToOutbound(packet v2net.Packet) ray.InboundRay {
+func (this *Point) DispatchToOutbound(packet v2net.Packet) ray.InboundRay {
 	direct := ray.NewRay()
 	dest := packet.Destination()
 
-	if p.router != nil {
-		tag, err := p.router.TakeDetour(dest)
+	if this.router != nil {
+		tag, err := this.router.TakeDetour(dest)
 		if err == nil {
-			handler, found := p.odh[tag]
+			handler, found := this.odh[tag]
 			if found {
 				go handler.Dispatch(packet, direct)
 				return direct
@@ -144,6 +144,6 @@ func (p *Point) DispatchToOutbound(packet v2net.Packet) ray.InboundRay {
 		}
 	}
 
-	go p.och.Dispatch(packet, direct)
+	go this.och.Dispatch(packet, direct)
 	return direct
 }

+ 2 - 2
proxy/blackhole/blackhole.go

@@ -16,7 +16,7 @@ func NewBlackHole() *BlackHole {
 	return &BlackHole{}
 }
 
-func (bh *BlackHole) Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error {
+func (this *BlackHole) Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error {
 	if chunk := firstPacket.Chunk(); chunk != nil {
 		chunk.Release()
 	}
@@ -31,7 +31,7 @@ func (bh *BlackHole) Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) err
 type BlackHoleFactory struct {
 }
 
-func (factory BlackHoleFactory) Create(config interface{}) (connhandler.OutboundConnectionHandler, error) {
+func (this BlackHoleFactory) Create(config interface{}) (connhandler.OutboundConnectionHandler, error) {
 	return NewBlackHole(), nil
 }