Skip to content

Commit

Permalink
Merge pull request #46 from synfinatic/reuse-port
Browse files Browse the repository at this point in the history
use reuse port
  • Loading branch information
synfinatic authored Oct 3, 2021
2 parents 7c40540 + 9342f34 commit beb075d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# AlpacaScope Changelog

## Unreleased
## v2.2.1 - 2021-10-03

Changed:

- ClientId is now randomized per Alpaca protocol spec
- Will attempt to Connect to the telescope if Alpaca reports the connected
state is false.
- Update to Fyne 2.1.0
- Use SO_REUSEPORT to avoid bugs. #44

## v2.2.0 - 2021-08-02

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ require (
fyne.io/fyne/v2 v2.1.0
github.com/go-resty/resty/v2 v2.3.0
github.com/kr/text v0.2.0 // indirect
github.com/libp2p/go-reuseport v0.1.0
github.com/mattn/go-colorable v0.1.8
github.com/sirupsen/logrus v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.6.1
github.com/stretchr/testify v1.7.0
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
Expand Down
7 changes: 5 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/libp2p/go-reuseport v0.1.0 h1:0ooKOx2iwyIkf339WCZ2HN3ujTDbkK0PjC7JVoP1AiM=
github.com/libp2p/go-reuseport v0.1.0/go.mod h1:bQVn9hmfcTaoo0c9v5pBhOarsU1eNOBZdaAd2hzXRKU=
github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2OJReAmwzKivcYyremnibWGbK7WfftHzc=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
Expand All @@ -58,8 +60,8 @@ github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9/go.mod h1:mvWM0+15
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.3.8 h1:Nw158Q8QN+CPgTmVRByhVwapp8Mm1e2blinhmx4wx5E=
Expand All @@ -77,6 +79,7 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
7 changes: 4 additions & 3 deletions skyfi/skyfi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"time"

reuse "github.com/libp2p/go-reuseport"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -52,7 +53,7 @@ func findIPinCIDR(ip string) (string, error) {
* Go Routine for handling SkyFi Discovery
*/
func ReplyDiscover() {
pc, err := net.ListenPacket("udp4", fmt.Sprintf(":%d", SKYFI_PORT))
pc, err := reuse.ListenPacket("udp4", fmt.Sprintf(":%d", SKYFI_PORT))
if err != nil {
log.Errorf("Unable to open SkyFi discovery listen socket: %s", err.Error())
return
Expand Down Expand Up @@ -108,7 +109,7 @@ type DiscoveryPacket struct {
*/
func ReplyDiscoverWithShutdown(shutdown chan bool) error {
quit := false
pc, err := net.ListenPacket("udp4", fmt.Sprintf(":%d", SKYFI_PORT))
pc, err := reuse.ListenPacket("udp4", fmt.Sprintf(":%d", SKYFI_PORT))
if err != nil {
return fmt.Errorf("Unable to start SkyFi discovery: %s", err.Error())
}
Expand Down Expand Up @@ -183,7 +184,7 @@ func ReplyDiscoverWithShutdown(shutdown chan bool) error {
* enough of the client side SkyFi protocol to get a SkyFi device to respond
*/
func GetDiscover(name string, tries int) ([]byte, error) {
pc, err := net.ListenPacket("udp4", fmt.Sprintf(":%d", SKYFI_PORT))
pc, err := reuse.ListenPacket("udp4", fmt.Sprintf(":%d", SKYFI_PORT))
if err != nil {
return []byte{}, fmt.Errorf("Unable to open SkyFi discovery listen socket: %s", err.Error())
}
Expand Down

0 comments on commit beb075d

Please sign in to comment.