Removed unused TCP function from network.go
This commit is contained in:
-26
@@ -2,11 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/soypat/cyw43439"
|
||||
@@ -172,29 +169,6 @@ func InitNetwork(ssid, pass string) (*NetworkStack, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (ns *NetworkStack) DialTCP(ctx context.Context, hostIP string, port uint16) (net.Conn, error) {
|
||||
rIP, err := netip.ParseAddr(hostIP)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid host IPv4: %w", err)
|
||||
}
|
||||
|
||||
laddr := net.TCPAddrFromAddrPort(netip.AddrPortFrom(ns.localIP, 0))
|
||||
raddr := net.TCPAddrFromAddrPort(netip.AddrPortFrom(rIP, port))
|
||||
|
||||
const sockstream = 0x1
|
||||
c, err := ns.gostack.Socket(ctx, "tcp", syscall.AF_INET, sockstream, laddr, raddr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("socket dial: %w", err)
|
||||
}
|
||||
|
||||
conn, ok := c.(net.Conn)
|
||||
if !ok {
|
||||
return nil, errors.New("socket did not return a stream connection")
|
||||
}
|
||||
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func stackLoop(ctx context.Context, stack *xnet.StackAsync, adapter *CywAdapter) {
|
||||
frameLength, _ := adapter.MaxFrameLength()
|
||||
buf := make([]byte, frameLength)
|
||||
|
||||
Reference in New Issue
Block a user