Skip to content

Commit

Permalink
No estaba utilizando address en ListenAndServe()
Browse files Browse the repository at this point in the history
  • Loading branch information
vcarceler committed May 21, 2024
1 parent 79e71ac commit 382e877
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Binary file modified sirin-go
Binary file not shown.
27 changes: 14 additions & 13 deletions sirin.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
/* This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with this
You should have received a copy of the GNU General Public License along with this
program. If not, see <https://www.gnu.org/licenses/>. */

package main
Expand All @@ -24,9 +24,9 @@ import (
)

type request struct {
playbook string
playbook string
timestamp time.Time
pending bool
pending bool
}

var registered map[string]*request
Expand Down Expand Up @@ -99,7 +99,7 @@ func listPendingRequests(w http.ResponseWriter, r *http.Request) {
return
}

log.Printf("/listpendingrequests/ remoteaddress=%s count=%d",r.RemoteAddr, len(registered))
log.Printf("/listpendingrequests/ remoteaddress=%s count=%d", r.RemoteAddr, len(registered))

salida := ""
for host, req := range registered {
Expand Down Expand Up @@ -133,7 +133,7 @@ func register(w http.ResponseWriter, r *http.Request) {
message = message + " newrequest=false"
elapsed := now.Sub(req.timestamp)
message = fmt.Sprintf("%s elapsed=%s timeout=%s", message, elapsed, duration)

// Comprobamos si ha pasado el timeout
if elapsed > duration {
// Actualizo la solicitud
Expand Down Expand Up @@ -168,11 +168,12 @@ func main() {
}

log.Printf("sirin -address %s -port %d -secret XXXX -timeout %s", address, port, timeout)

http.HandleFunc("/gethosts/{secret}/{playbook}", getHosts)
http.HandleFunc("/getnumberofrequests/", getNumberOfRequests)
http.HandleFunc("/listpendingrequests/", listPendingRequests)
http.HandleFunc("/register/", register)

log.Fatal(http.ListenAndServe(":8080", nil))
}
addr := fmt.Sprintf("%s:%d", address, port)
log.Fatal(http.ListenAndServe(addr, nil))
}

0 comments on commit 382e877

Please sign in to comment.