Browse Source

speed test

Abhishek Kondur 2 years ago
parent
commit
83be42b5d8
2 changed files with 4 additions and 3 deletions
  1. 2 2
      nm-proxy/proxy/wireguard.go
  2. 2 1
      nm-proxy/server/server.go

+ 2 - 2
nm-proxy/proxy/wireguard.go

@@ -24,7 +24,7 @@ func NewProxy(config Config) *Proxy {
 
 // proxyToRemote proxies everything from Wireguard to the RemoteKey peer
 func (p *Proxy) ProxyToRemote() {
-	buf := make([]byte, 1500)
+
 	peers := common.WgIFaceMap[p.Config.WgInterface.Name]
 	go func() {
 		<-p.Ctx.Done()
@@ -53,7 +53,7 @@ func (p *Proxy) ProxyToRemote() {
 
 			return
 		default:
-
+			buf := make([]byte, 1500)
 			n, err := p.LocalConn.Read(buf)
 			if err != nil {
 				log.Println("ERRR READ: ", err)

+ 2 - 1
nm-proxy/server/server.go

@@ -36,7 +36,7 @@ type ProxyServer struct {
 func (p *ProxyServer) Listen(ctx context.Context) {
 
 	// Buffer with indicated body size
-	buffer := make([]byte, 1532)
+
 	for {
 
 		select {
@@ -54,6 +54,7 @@ func (p *ProxyServer) Listen(ctx context.Context) {
 			return
 		default:
 			// Read Packet
+			buffer := make([]byte, 1532)
 			n, source, err := p.Server.ReadFromUDP(buffer)
 			if err != nil { // in future log errors?
 				log.Println("RECV ERROR: ", err)