Skip to content

Commit

Permalink
Fix building for Linux targets.
Browse files Browse the repository at this point in the history
Fixes icedream#1.
  • Loading branch information
icedream committed Jan 3, 2021
1 parent f9f1911 commit c1336b1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
8 changes: 0 additions & 8 deletions listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"math/rand"
"net"
"syscall"
"time"
)

Expand Down Expand Up @@ -41,13 +40,6 @@ var stagelinqDiscoveryBroadcastAddress = &net.UDPAddr{

var magicBytes = []byte("airD")

func setSocketControlForReusePort(network, address string, c syscall.RawConn) error {
return c.Control(func(fd uintptr) {
syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
})
}

// Listener listens on UDP port 51337 for StagelinQ devices and announces itself in the same way.
type Listener struct {
softwareName string
Expand Down
12 changes: 12 additions & 0 deletions listener_nonwindows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//+build !windows

package stagelinq

import "syscall"

func setSocketControlForReusePort(network, address string, c syscall.RawConn) error {
return c.Control(func(fd uintptr) {
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
})
}
12 changes: 12 additions & 0 deletions listener_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//+build windows

package stagelinq

import "syscall"

func setSocketControlForReusePort(network, address string, c syscall.RawConn) error {
return c.Control(func(fd uintptr) {
syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
})
}

0 comments on commit c1336b1

Please sign in to comment.