Skip to content

Commit

Permalink
0.4.6 minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yinghuocho committed Dec 10, 2016
1 parent 39a39b4 commit 32f6264
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
20 changes: 11 additions & 9 deletions client/Makefile 100644 → 100755
@@ -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 && \
Expand All @@ -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 <yinghuocho@gmail.com>" --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
Expand All @@ -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

Expand Down
26 changes: 13 additions & 13 deletions client/main.go
Expand Up @@ -34,7 +34,7 @@ import (
)

const (
FIREFLY_VERSION = "0.4.4"
FIREFLY_VERSION = "0.4.6"
)

type clientOptions struct {
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions client/tunnel.go
Expand Up @@ -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)
Expand All @@ -125,15 +126,15 @@ 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)
log.Printf("connect attempt timed out")
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)
}
Expand Down

0 comments on commit 32f6264

Please sign in to comment.