diff --git a/client/Makefile b/client/Makefile old mode 100644 new mode 100755 index f3ec321..09cabcb --- a/client/Makefile +++ b/client/Makefile @@ -1,9 +1,9 @@ -VERSION := 0.4.4 -SHORTVERSION := 0.4.4 +VERSION := 0.4.6 +SHORTVERSION := 0.4.6 .PHONY: windows package-windows linux package-linux darwin package-darwin clean -define fpm-debian-build +define fpm-debian-build echo "Running fpm-debian-build" && \ PKG_ARCH=$1 && \ VERSION=$2 && \ @@ -17,28 +17,30 @@ define fpm-debian-build chmod -R 755 $$WORKDIR && \ \ cp $$INSTALLER_RESOURCES/firefly.desktop $$WORKDIR/usr/share/applications && \ + chmod 664 $$WORKDIR/usr/share/applications/firefly.desktop && \ cp $$INSTALLER_RESOURCES/firefly_256.png $$WORKDIR/usr/share/icons/hicolor/256x256/apps/firefly.png && \ + chmod 664 $$WORKDIR/usr/share/icons/hicolor/256x256/apps/firefly.png && \ \ cp $3 $$WORKDIR/usr/bin/firefly-bin && \ cp $$INSTALLER_RESOURCES/firefly.sh $$WORKDIR/usr/bin/firefly && \ \ - chmod -x $$WORKDIR/usr/bin/firefly-bin && \ - chmod +x $$WORKDIR/usr/bin/firefly && \ + chmod 664 $$WORKDIR/usr/bin/firefly-bin && \ + chmod 775 $$WORKDIR/usr/bin/firefly && \ \ fpm --depends "libappindicator3-1" --license BSD --description "$$DESC" --vendor yinghuocho --maintainer "yinghuocho " --url https://gofirefly.org/ -a $$PKG_ARCH -s dir -t deb -n firefly -v $$VERSION -C $$WORKDIR -f usr; endef windows: GOOS=windows GOARCH=386 go build -ldflags="-w -s -H windowsgui" -a -o firefly.exe - + package-windows: windows sed "s/__VERSION__/${VERSION}/g" installer/windows/firefly.nsi > firefly-${VERSION}.nsi @echo "Please execute firefly-${VERSION}.nsi under windows" -linux: +linux: GOOS=linux GOARCH=amd64 go build -ldflags="-w -s -linkmode internal" -a -o firefly -linux32: +linux32: GOOS=linux GOARCH=386 go build -ldflags="-w -s -linkmode internal" -a -o firefly32 package-linux: linux @@ -60,7 +62,7 @@ package-darwin: darwin rm -rf firefly-${VERSION}.dmg appdmg --quiet installer/darwin/firefly-${VERSION}.dmg.json firefly-${VERSION}.dmg rm -rf installer/darwin/firefly-${VERSION}.dmg.json - mv firefly-${VERSION}.dmg firefly-${VERSION}.dmg.zlib + mv firefly-${VERSION}.dmg firefly-${VERSION}.dmg.zlib hdiutil convert -quiet -format UDBZ -o firefly-${VERSION}.dmg firefly-${VERSION}.dmg.zlib rm firefly-${VERSION}.dmg.zlib diff --git a/client/main.go b/client/main.go index b75d331..c49dc3a 100644 --- a/client/main.go +++ b/client/main.go @@ -34,7 +34,7 @@ import ( ) const ( - FIREFLY_VERSION = "0.4.4" + FIREFLY_VERSION = "0.4.6" ) type clientOptions struct { @@ -502,11 +502,11 @@ func (c *fireflyClient) _main() { nil, ) go func() { - err := c.tunnelProxy.Serve(c.tunnelListener) - if err != nil { - log.Printf("FATAL: error to serve tunnel client (SOCKS): %s", err) + e := c.tunnelProxy.Serve(c.tunnelListener) + if e != nil { + log.Printf("FATAL: error to serve tunnel client (SOCKS): %s", e) } - c.exit(err) + c.exit(e) }() tunnelProxyAddr := c.tunnelListener.Addr().String() log.Printf("tunnel proxy (SOCKS) listens on %s", tunnelProxyAddr) @@ -527,11 +527,11 @@ func (c *fireflyClient) _main() { &gosocks.AnonymousServerAuthenticator{}, ) go func() { - err := c.socksProxy.Serve(c.socksListener) - if err != nil { - log.Printf("FATAL: error to serve SOCKS proxy: %s", err) + e := c.socksProxy.Serve(c.socksListener) + if e != nil { + log.Printf("FATAL: error to serve SOCKS proxy: %s", e) } - c.exit(err) + c.exit(e) }() log.Printf("SOCKS proxy listens on %s", c.options.localSocksAddr) @@ -550,11 +550,11 @@ func (c *fireflyClient) _main() { c.httpProxy.OnRequest().DoFunc(http2Socks.HTTP) c.httpProxy.OnRequest().HandleConnectFunc(http2Socks.HTTPS) go func() { - err := http.Serve(c.httpListener, c.httpProxy) - if err != nil { - log.Printf("FATAL: error to serve HTTP/S proxy: %s", err) + e := http.Serve(c.httpListener, c.httpProxy) + if e != nil { + log.Printf("FATAL: error to serve HTTP/S proxy: %s", e) } - c.exit(err) + c.exit(e) }() log.Printf("HTTP/S proxy listens on %s", localHTTPAddr) diff --git a/client/tunnel.go b/client/tunnel.go index cd5eb2c..148c068 100644 --- a/client/tunnel.go +++ b/client/tunnel.go @@ -98,7 +98,8 @@ func (t *tunnelHandler) sortPeers() []tunnelPeer { j := rand.Intn(i + 1) peers[i], peers[j] = peers[j], peers[i] } - sort.Reverse(&peerSorter{peers: peers, by: by}) + // remove shuffle? because the sort is non-stable anyway + sort.Sort(sort.Reverse(&peerSorter{peers: peers, by: by})) groups = append(groups, peers) } all := make([]tunnelPeer, cnt) @@ -125,7 +126,7 @@ func (t *tunnelHandler) sortPeers() []tunnelPeer { func (t *tunnelHandler) muxClient() *mux.Client { start := time.Now() conn, succ, failed := t.dialParallel(10 * time.Minute) - ms := int(time.Now().Sub(start).Nanoseconds() / 1000) + ms := int(time.Now().Sub(start).Nanoseconds() / 1000000) t.savePeerState(succ, failed) if conn == nil { t.state.event("client", "connect-timeout", "", 0) @@ -133,7 +134,7 @@ func (t *tunnelHandler) muxClient() *mux.Client { return nil } p := succ.serialize() - log.Printf("connected to peer: %s", p) + log.Printf("connected to peer: %s|%v", p, ms) t.state.event("client", "connect-succ", p, ms) return mux.NewClient(conn) }