Last active
June 17, 2021 12:41
-
-
Save Li4n0/21aa0bec2d626114a729ca2677efb05a to your computer and use it in GitHub Desktop.
Use Golang's SSE client connect to RevSuit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package client | |
import ( | |
"crypto/tls" | |
"log" | |
"time" | |
"net" | |
"net/http" | |
"github.com/r3labs/sse" | |
"gopkg.in/cenkalti/backoff.v1" | |
) | |
func Listen() { | |
client := sse.NewClient("http://127.0.0.1:10000/revsuit/api/events") | |
client.Connection.Transport = &http.Transport{ | |
TLSClientConfig: &tls.Config{InsecureSkipVerify: true} | |
} | |
// Set token. | |
client.Headers = map[string]string{"Token": "your token"} | |
//Set reconnection policy. | |
reconnectStrategy := backoff.NewExponentialBackOff() | |
reconnectStrategy.MaxElapsedTime = time.Minute | |
client.ReconnectStrategy = reconnectStrategy | |
//Listening channel. | |
err := client.Subscribe("messages", func(event *sse.Event) { | |
log.Println(string(event.Data)) | |
// Look up this flag in your local database of recorded requests | |
//to find which request attack was successful for the scanner. | |
searchRequest(event.Data) | |
}) | |
if err != nil { | |
log.Fatal("Disconnect from reverse platform, please check network or reverse connection platform's status.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment