From ba5c6a9ed3da9cd3c85715f946cb978757b2df55 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 13 Aug 2019 18:43:03 +0800 Subject: [PATCH] cleanup --- filter/icmp.go | 5 +-- proxy/socks.go | 4 +-- scripts/release.sh | 80 ---------------------------------------------- 3 files changed, 5 insertions(+), 84 deletions(-) delete mode 100644 scripts/release.sh diff --git a/filter/icmp.go b/filter/icmp.go index f1e7786..8d44c31 100644 --- a/filter/icmp.go +++ b/filter/icmp.go @@ -16,7 +16,8 @@ func NewICMPFilter(w io.Writer) Filter { } func (f *icmpFilter) Write(buf []byte) (int, error) { - if buf[9] == packet.PROTOCOL_ICMP { + switch buf[9] { + case packet.PROTOCOL_ICMP: payload := make([]byte, len(buf)) copy(payload, buf) go func(data []byte) { @@ -25,7 +26,7 @@ func (f *icmpFilter) Write(buf []byte) (int, error) { } }(payload) return len(buf), nil - } else { + default: return f.writer.Write(buf) } } diff --git a/proxy/socks.go b/proxy/socks.go index 7bfc867..aa3d906 100644 --- a/proxy/socks.go +++ b/proxy/socks.go @@ -14,8 +14,8 @@ const socks5Version = 5 // SOCKS request commands as defined in RFC 1928 section 4. const ( - socks5Connect = 1 - socks5Bind = 2 + // socks5Connect = 1 + // socks5Bind = 2 socks5UDPAssociate = 3 ) diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100644 index 7c8a4c7..0000000 --- a/scripts/release.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -# Create GITHUB_API_TOKEN and export it first. - -set -x - -tag=v1.7 -description="- Support IPv6 on macOS and Linux\n- Utilizing V2Ray's DNS client for DNS resolving" -list_assets_cmd="ls -1 build/*.zip" -token= -if [ -z ${GITHUB_API_TOKEN+x} ]; then - read -p 'Input the github API token:' token -else - token=$GITHUB_API_TOKEN -fi - -declare -a executables=(\ -"tun2socks-darwin-10.6-amd64" \ -"tun2socks-linux-386" \ -"tun2socks-linux-amd64" \ -"tun2socks-linux-arm64" \ -"tun2socks-linux-mips" \ -"tun2socks-linux-mips64" \ -"tun2socks-linux-mips64le" \ -"tun2socks-linux-mipsle" \ -"tun2socks-windows-4.0-386.exe" \ -"tun2socks-windows-4.0-amd64.exe" \ -) -eval $list_assets_cmd -if [ $? -ne 0 ]; then - cd build - for i in ${executables[@]}; do - zip "$i.zip" "$i" - done - cd .. -fi - -owner=eycorsican -repo=go-tun2socks -base_url=https://api.github.com - -content_type_json="Content-Type: application/json" -content_type_zip="Content-Type: application/zip" - -api_create_release=/repos/$owner/$repo/releases -api_get_release_by_tag=/repos/$owner/$repo/releases/tags/$tag -api_create_release_data="{\ -\"tag_name\": \"${tag}\",\ -\"target_commitish\": \"master\",\ -\"name\": \"${tag}\", -\"body\": \"${description}\", -\"draft\": false,\ -\"prerelease\": false\ -}" - -# Get the release id by tag name. -release_id=`curl -u $owner:$token -H "$content_type_json" -X GET "${base_url}${api_get_release_by_tag}" | \ -python -c "import sys;import json;print(json.loads(\"\".join(sys.stdin.readlines()))[\"id\"])"` 2>/dev/null - -# If there is release with the tag exists, delete it first. -if [ $? -eq 0 ]; then - api_delete_release=/repos/$owner/$repo/releases/$release_id - curl -u $owner:$token -H "$content_type_json" -X DELETE "${base_url}${api_delete_release}" -fi - -# Create a release. -curl -u $owner:$token -H "$content_type_json" -X POST "${base_url}${api_create_release}" --data "${api_create_release_data}" - -# Get the release id by tag name. -release_id=`curl -u $owner:$token -H "$content_type_json" -X GET "${base_url}${api_get_release_by_tag}" | \ -python -c "import sys;import json;print(json.loads(\"\".join(sys.stdin.readlines()))[\"id\"])"` - -# Upload assets. -eval $list_assets_cmd | while read -r asset_name; do - upload_url=https://uploads.github.com/repos/$owner/$repo/releases/$release_id/assets?name=$(basename $asset_name) - curl --progress-bar -u $owner:$token -H "$content_type_zip" --data-binary @"$asset_name" -X POST $upload_url - if [ $? -ne "0" ]; then - exit 1 - fi -done