This commit is contained in:
hedy 2023-07-22 17:25:36 +08:00
parent 14c6df05e0
commit 0e86f4304b
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
2 changed files with 4 additions and 5 deletions

View File

@ -5,13 +5,12 @@ builds:
- CGO_ENABLED=0
goos:
- linux
# - windows
- windows
- darwin
- freebsd
- netbsd
- openbsd
goarch:
- 386
- amd64
- arm64
- arm

6
nex.go
View File

@ -22,14 +22,13 @@ type NexResponse struct {
func NexParsedURL(u *url.URL) (res *NexResponse, err error) {
host := u.Host
if u.Port() == "" {
host += ":1900"
host += ":1900" // Default port
}
// Connect to server
// Connect to server, no TLS
conn, err := net.Dial("tcp", host)
if err != nil {
return
}
// Send request
path := u.Path
if u.Path == "" {
path = "/"
@ -38,6 +37,7 @@ func NexParsedURL(u *url.URL) (res *NexResponse, err error) {
if !strings.HasSuffix(path, "/") {
fileExt = strings.SplitN(path, ".", 2)[1]
}
// Requests are simply file paths
conn.Write([]byte(fmt.Sprintf("%s\n", path)))
// Receive and parse response header
reader := bufio.NewReader(conn)