mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-11-01 04:22:44 +08:00
cleanup
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user