mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-24 02:25:21 +00:00
Merge pull request #137 from yggdrasil-network/develop
Integrate history from develop for v0.2.1
This commit is contained in:
commit
b415adee6d
@ -1,26 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Merge commits from this branch are counted
|
||||
DEVELOPBRANCH="yggdrasil-network/develop"
|
||||
|
||||
# Get the last tag
|
||||
TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*" 2>/dev/null)
|
||||
|
||||
# Get the number of commits from the last tag
|
||||
COUNT=$(git rev-list $TAG..HEAD --count 2>/dev/null)
|
||||
# Get last merge to master
|
||||
MERGE=$(git rev-list $TAG..master --grep "from $DEVELOPBRANCH" 2>/dev/null | head -n 1)
|
||||
|
||||
# Get the number of merges since the last merge to master
|
||||
PATCH=$(git rev-list $TAG..master --count --merges --grep="from $DEVELOPBRANCH" 2>/dev/null)
|
||||
|
||||
# If it fails then there's no last tag - go from the first commit
|
||||
if [ $? != 0 ]; then
|
||||
COUNT=$(git rev-list HEAD --count 2>/dev/null)
|
||||
PATCH=$(git rev-list HEAD --count 2>/dev/null)
|
||||
|
||||
printf 'v0.0.%d' "$COUNT"
|
||||
printf 'v0.0.%d' "$PATCH"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Get the number of merges on the current branch since the last tag
|
||||
BUILD=$(git rev-list $TAG..HEAD --count --merges)
|
||||
|
||||
# Split out into major, minor and patch numbers
|
||||
MAJOR=$(echo $TAG | cut -c 2- | cut -d "." -f 1)
|
||||
MINOR=$(echo $TAG | cut -c 2- | cut -d "." -f 2)
|
||||
|
||||
# Get the current checked out branch
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
# Output in the desired format
|
||||
if [ $COUNT = 0 ]; then
|
||||
if [ $PATCH = 0 ]; then
|
||||
printf 'v%d.%d' "$MAJOR" "$MINOR"
|
||||
else
|
||||
printf 'v%d.%d.%d' "$MAJOR" "$MINOR" "$COUNT"
|
||||
printf 'v%d.%d.%d' "$MAJOR" "$MINOR" "$PATCH"
|
||||
fi
|
||||
|
||||
# Add the build tag on non-master branches
|
||||
if [ $BRANCH != "master" ]; then
|
||||
if [ $BUILD != 0 ]; then
|
||||
printf -- "-%04d" "$BUILD"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
)
|
||||
|
||||
const tcp_msgSize = 2048 + 65535 // TODO figure out what makes sense
|
||||
const tcp_timeout = 6 * time.Second
|
||||
|
||||
// Wrapper function for non tcp/ip connections.
|
||||
func setNoDelay(c net.Conn, delay bool) {
|
||||
@ -109,6 +110,8 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string) {
|
||||
} else {
|
||||
iface.calls[saddr] = struct{}{}
|
||||
defer func() {
|
||||
// Block new calls for a little while, to mitigate livelock scenarios
|
||||
time.Sleep(tcp_timeout)
|
||||
iface.mutex.Lock()
|
||||
delete(iface.calls, saddr)
|
||||
iface.mutex.Unlock()
|
||||
@ -162,7 +165,7 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
timeout := time.Now().Add(6 * time.Second)
|
||||
timeout := time.Now().Add(tcp_timeout)
|
||||
sock.SetReadDeadline(timeout)
|
||||
_, err = sock.Read(metaBytes)
|
||||
if err != nil {
|
||||
@ -257,7 +260,7 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) {
|
||||
atomic.AddUint64(&p.bytesSent, uint64(len(tcp_msg)+len(msgLen)+len(msg)))
|
||||
util_putBytes(msg)
|
||||
}
|
||||
timerInterval := 4 * time.Second
|
||||
timerInterval := tcp_timeout * 2 / 3
|
||||
timer := time.NewTimer(timerInterval)
|
||||
defer timer.Stop()
|
||||
for {
|
||||
@ -334,7 +337,7 @@ func (iface *tcpInterface) reader(sock net.Conn, in func([]byte)) {
|
||||
bs := make([]byte, 2*tcp_msgSize)
|
||||
frag := bs[:0]
|
||||
for {
|
||||
timeout := time.Now().Add(6 * time.Second)
|
||||
timeout := time.Now().Add(tcp_timeout)
|
||||
sock.SetReadDeadline(timeout)
|
||||
n, err := sock.Read(bs[len(frag):])
|
||||
if err != nil || n == 0 {
|
||||
|
@ -117,7 +117,7 @@ func main() {
|
||||
// of it - remove it and decode back down into UTF-8. This is necessary
|
||||
// because hjson doesn't know what to do with UTF-16 and will panic
|
||||
if bytes.Compare(config[0:2], []byte{0xFF, 0xFE}) == 0 ||
|
||||
bytes.Compare(config[0:2], []byte{0xFF, 0xFF}) == 0 {
|
||||
bytes.Compare(config[0:2], []byte{0xFE, 0xFF}) == 0 {
|
||||
utf := unicode.UTF16(unicode.BigEndian, unicode.UseBOM)
|
||||
decoder := utf.NewDecoder()
|
||||
config, err = decoder.Bytes(config)
|
||||
|
Loading…
Reference in New Issue
Block a user