Git Product home page Git Product logo

Comments (2)

wzshiming avatar wzshiming commented on May 26, 2024
cd cmd/socks5/ &&
go build &&
cd ../.. &&
./cmd/socks5/socks5 &
socks5_pid=$!;

The socks5_pid is not the pid of socks5 but the pipeline ... && ... && ... &

cd cmd/socks5/ &&
go build &&
cd ../..

#########################

./cmd/socks5/socks5 &
socks5_pid=$!

Separate builds and runs to get their pid correctly

from socks5.

milahu avatar milahu commented on May 26, 2024

facepalm. thanks!

run.sh
#!/usr/bin/env bash

set -e

proxy_port=1080

netstat_out="$(netstat -nap 2>/dev/null | grep -w $proxy_port || true)"
if [ -n "$netstat_out" ]; then
  echo "error: address already in use"
  echo "found $(echo "$netstat_out" | wc -l) open connections with port $proxy_port:"
  echo "$netstat_out"
  #if true; then
  if false; then
    exit 1
  else
    echo "killing worker procs using port $proxy_port"
    netstat -nap 2>/dev/null | grep -w $proxy_port | awk '{ print $7 }' | cut -d/ -f1 | grep -vxFe - | xargs -r kill
  fi
fi

cd cmd/socks5/
go build
cd ../..

./cmd/socks5/socks5 &

socks5_pid=$!;
echo socks5_pid: $socks5_pid;
sleep 2;

#if true; then
if false; then
  # socks5
  curl --no-keepalive --proxy socks5://localhost:$proxy_port https://httpbin.org/ip;
else
  # socks5h
  curl --no-keepalive --proxy socks5h://localhost:$proxy_port https://httpbin.org/ip;
fi

kill $socks5_pid

now after running some cycles, there are some open connections
which disappear after a few seconds

$ netstat -nap 2>/dev/null | grep -w 1080
tcp6       0      0 ::1:59198               ::1:1080                TIME_WAIT   -                   
tcp6       0      0 ::1:40238               ::1:1080                TIME_WAIT   -                   
tcp6       0      0 ::1:54384               ::1:1080                TIME_WAIT   -                   

but they are not blocking the start of a new proxy server

from socks5.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.