Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added admin features #64

Merged
merged 11 commits into from
Dec 26, 2019
Prev Previous commit
Next Next commit
Changed how to handle listener closes
  • Loading branch information
antoniomika committed Dec 24, 2019
commit 137265d28ad669c2737600950236bef9a5ffe57e
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
- name: Login to GitHub Docker Registry
- name: Login to Docker Registry
env:
DOCKER_USERNAME: ${{ secrets.GITHUB_DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_DOCKER_PASSWORD }}
Expand All @@ -25,6 +25,7 @@ jobs:
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
REF="${BRANCH_NAME:-master}"
OTHER_TAGS=""

if [[ ${GITHUB_REF} =~ ^refs\/tags\/v.*$ ]]
then
REF="${GITHUB_REF//refs\/tags\/}"
Expand Down
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,19 @@ func main() {
func (s *SSHConnection) CleanUp(state *State) {
close(s.Close)
s.SSHConn.Close()
s.Listeners.Range(func(key, val interface{}) bool {
_, ok := key.(*net.UnixAddr)

if ok {
actualUnixListener := val.(*net.UnixListener)
actualUnixListener.Close()
} else {
actualTCPListener := val.(*net.TCPListener)
actualTCPListener.Close()
}

return true
})
state.SSHConnections.Delete(s.SSHConn.RemoteAddr())
log.Println("Closed SSH connection for:", s.SSHConn.RemoteAddr(), "user:", s.SSHConn.User())
}