|
@@ -1226,7 +1226,7 @@ type sshClient struct {
|
|
|
preHandshakeRandomStreamMetrics randomStreamMetrics
|
|
preHandshakeRandomStreamMetrics randomStreamMetrics
|
|
|
postHandshakeRandomStreamMetrics randomStreamMetrics
|
|
postHandshakeRandomStreamMetrics randomStreamMetrics
|
|
|
sendAlertRequests chan protocol.AlertRequest
|
|
sendAlertRequests chan protocol.AlertRequest
|
|
|
- sentAlertRequests map[protocol.AlertRequest]bool
|
|
|
|
|
|
|
+ sentAlertRequests map[string]bool
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type trafficState struct {
|
|
type trafficState struct {
|
|
@@ -1318,7 +1318,7 @@ func newSshClient(
|
|
|
stopRunning: stopRunning,
|
|
stopRunning: stopRunning,
|
|
|
stopped: make(chan struct{}),
|
|
stopped: make(chan struct{}),
|
|
|
sendAlertRequests: make(chan protocol.AlertRequest, ALERT_REQUEST_QUEUE_BUFFER_SIZE),
|
|
sendAlertRequests: make(chan protocol.AlertRequest, ALERT_REQUEST_QUEUE_BUFFER_SIZE),
|
|
|
- sentAlertRequests: make(map[protocol.AlertRequest]bool),
|
|
|
|
|
|
|
+ sentAlertRequests: make(map[string]bool),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
client.tcpTrafficState.availablePortForwardCond = sync.NewCond(new(sync.Mutex))
|
|
client.tcpTrafficState.availablePortForwardCond = sync.NewCond(new(sync.Mutex))
|
|
@@ -2682,7 +2682,7 @@ func (sshClient *sshClient) runAlertSender() {
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
|
sshClient.Lock()
|
|
sshClient.Lock()
|
|
|
- sshClient.sentAlertRequests[request] = true
|
|
|
|
|
|
|
+ sshClient.sentAlertRequests[fmt.Sprintf("%+v", request)] = true
|
|
|
sshClient.Unlock()
|
|
sshClient.Unlock()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2694,7 +2694,7 @@ func (sshClient *sshClient) runAlertSender() {
|
|
|
// not block until the queue exceeds ALERT_REQUEST_QUEUE_BUFFER_SIZE.
|
|
// not block until the queue exceeds ALERT_REQUEST_QUEUE_BUFFER_SIZE.
|
|
|
func (sshClient *sshClient) enqueueAlertRequest(request protocol.AlertRequest) {
|
|
func (sshClient *sshClient) enqueueAlertRequest(request protocol.AlertRequest) {
|
|
|
sshClient.Lock()
|
|
sshClient.Lock()
|
|
|
- if sshClient.sentAlertRequests[request] {
|
|
|
|
|
|
|
+ if sshClient.sentAlertRequests[fmt.Sprintf("%+v", request)] {
|
|
|
sshClient.Unlock()
|
|
sshClient.Unlock()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -2706,20 +2706,46 @@ func (sshClient *sshClient) enqueueAlertRequest(request protocol.AlertRequest) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (sshClient *sshClient) enqueueDisallowedTrafficAlertRequest() {
|
|
func (sshClient *sshClient) enqueueDisallowedTrafficAlertRequest() {
|
|
|
- sshClient.enqueueAlertRequest(protocol.AlertRequest{
|
|
|
|
|
- Reason: protocol.PSIPHON_API_ALERT_DISALLOWED_TRAFFIC,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+
|
|
|
|
|
+ reason := protocol.PSIPHON_API_ALERT_DISALLOWED_TRAFFIC
|
|
|
|
|
+ actionURLs := sshClient.getAlertActionURLs(reason)
|
|
|
|
|
+
|
|
|
|
|
+ sshClient.enqueueAlertRequest(
|
|
|
|
|
+ protocol.AlertRequest{
|
|
|
|
|
+ Reason: protocol.PSIPHON_API_ALERT_DISALLOWED_TRAFFIC,
|
|
|
|
|
+ ActionURLs: actionURLs,
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (sshClient *sshClient) enqueueUnsafeTrafficAlertRequest(tags []BlocklistTag) {
|
|
func (sshClient *sshClient) enqueueUnsafeTrafficAlertRequest(tags []BlocklistTag) {
|
|
|
|
|
+
|
|
|
|
|
+ reason := protocol.PSIPHON_API_ALERT_UNSAFE_TRAFFIC
|
|
|
|
|
+ actionURLs := sshClient.getAlertActionURLs(reason)
|
|
|
|
|
+
|
|
|
for _, tag := range tags {
|
|
for _, tag := range tags {
|
|
|
- sshClient.enqueueAlertRequest(protocol.AlertRequest{
|
|
|
|
|
- Reason: protocol.PSIPHON_API_ALERT_UNSAFE_TRAFFIC,
|
|
|
|
|
- Subject: tag.Subject,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ sshClient.enqueueAlertRequest(
|
|
|
|
|
+ protocol.AlertRequest{
|
|
|
|
|
+ Reason: reason,
|
|
|
|
|
+ Subject: tag.Subject,
|
|
|
|
|
+ ActionURLs: actionURLs,
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (sshClient *sshClient) getAlertActionURLs(alertReason string) []string {
|
|
|
|
|
+
|
|
|
|
|
+ sshClient.Lock()
|
|
|
|
|
+ sponsorID, _ := getStringRequestParam(
|
|
|
|
|
+ sshClient.handshakeState.apiParams, "sponsor_id")
|
|
|
|
|
+ sshClient.Unlock()
|
|
|
|
|
+
|
|
|
|
|
+ return sshClient.sshServer.support.PsinetDatabase.GetAlertActionURLs(
|
|
|
|
|
+ alertReason,
|
|
|
|
|
+ sponsorID,
|
|
|
|
|
+ sshClient.geoIPData.Country,
|
|
|
|
|
+ sshClient.geoIPData.ASN)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (sshClient *sshClient) rejectNewChannel(newChannel ssh.NewChannel, logMessage string) {
|
|
func (sshClient *sshClient) rejectNewChannel(newChannel ssh.NewChannel, logMessage string) {
|
|
|
|
|
|
|
|
// We always return the reject reason "Prohibited":
|
|
// We always return the reject reason "Prohibited":
|