Skip to content
Permalink
Browse files

Changed how to handle listener closes

  • Loading branch information
antoniomika committed Dec 24, 2019
1 parent 1a0f9ce commit 137265d28ad669c2737600950236bef9a5ffe57e
Showing with 15 additions and 1 deletion.
  1. +2 −1 .github/workflows/docker.yml
  2. +13 −0 main.go
@@ -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 }}
@@ -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\/}"
13 main.go
@@ -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())
}

0 comments on commit 137265d

Please sign in to comment.
You can’t perform that action at this time.