-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
164 additions
and
99 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# To do | ||
|
||
- enable webhook authentication secret for spark: https://developer.ciscospark.com/webhooks-explained.html | ||
- encrypted websockets | ||
- tests for SSL mode | ||
- make healthz endpoint serve what is needs to serve to be a real healthz endpoint |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
// json that is sent back to the websocket client open connection | ||
type OpenHookResponse struct { | ||
Url string `json:"url"` | ||
} | ||
|
||
// acceptable json to foward | ||
// Fully open for now | ||
type HookMsg interface{} | ||
|
||
// json sent back on /status requests | ||
type StatusResponse struct { | ||
NbOpenHooks int `json:"nb_open_hooks"` | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
// concurrent management of open sessions | ||
|
||
import ( | ||
"log" | ||
"sync" | ||
|
||
"golang.org/x/net/websocket" | ||
) | ||
|
||
type Session struct { | ||
Connection *websocket.Conn | ||
Secret []byte | ||
} | ||
|
||
var ( | ||
mu sync.Mutex | ||
sessions = make(map[string]Session) | ||
) | ||
|
||
func session(id string) (Session, bool) { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
s, ok := sessions[id] | ||
return s, ok | ||
} | ||
|
||
func setSession(id string, s Session) { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
sessions[id] = s | ||
} | ||
|
||
func deleteSession(id string) { | ||
log.Printf("Removing websocket: %s\n", id) | ||
mu.Lock() | ||
defer mu.Unlock() | ||
delete(sessions, id) | ||
} | ||
|
||
func sessionsCount() int { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
return len(sessions) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/hmac" | ||
"crypto/sha1" | ||
) | ||
|
||
// CheckMAC reports whether messageSig is a valid HMAC tag for message. | ||
func validSignature(message, messageSig, secret []byte) bool { | ||
mac := hmac.New(sha1.New, secret) | ||
mac.Write(message) | ||
expectedMAC := mac.Sum(nil) | ||
// log.Printf("secret: %s", string(secret)) | ||
// log.Printf("messageSig: %x", string(messageSig)) | ||
// log.Printf("computedSig: %x", string(expectedMAC)) | ||
return hmac.Equal(messageSig, expectedMAC) | ||
} |
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
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
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
Oops, something went wrong.