64 lines
1.1 KiB
Go
64 lines
1.1 KiB
Go
|
package auth
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
|
||
|
"git.loafle.net/commons_go/logging"
|
||
|
"git.loafle.net/overflow/overflow_probes/probe/handler"
|
||
|
|
||
|
"github.com/gorilla/websocket"
|
||
|
)
|
||
|
|
||
|
type AuthHandler interface {
|
||
|
handler.Handler
|
||
|
}
|
||
|
|
||
|
type authHandlers struct {
|
||
|
c *websocket.Conn
|
||
|
apiKey *string
|
||
|
tempKey *string
|
||
|
}
|
||
|
|
||
|
type NoAuthProbe struct {
|
||
|
Host *Host `json:"host"`
|
||
|
Network *Network `json:"network"`
|
||
|
}
|
||
|
|
||
|
func NewHandler() AuthHandler {
|
||
|
h := &authHandlers{}
|
||
|
return h
|
||
|
}
|
||
|
|
||
|
func (h *authHandlers) Start() {
|
||
|
// c, _, err := websocket.DefaultDialer.Dial("ws://192.168.1.50:19190/auth", nil)
|
||
|
// if err != nil {
|
||
|
// logging.Logger.Fatal(fmt.Sprintf("auth: %v", err))
|
||
|
// }
|
||
|
// h.c = c
|
||
|
p := &NoAuthProbe{}
|
||
|
|
||
|
if h, err := getHost(); nil == err {
|
||
|
p.Host = h
|
||
|
}
|
||
|
|
||
|
if n, err := getNetwork(); nil == err {
|
||
|
p.Network = n
|
||
|
}
|
||
|
|
||
|
if buf, err := json.Marshal(*p); nil == err {
|
||
|
logging.Logger.Debug(fmt.Sprintf("p: %s", string(buf)))
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
func (h *authHandlers) listen() {
|
||
|
// 1. regist
|
||
|
// 2. wait for accept auth
|
||
|
}
|
||
|
|
||
|
func (h *authHandlers) Shutdown(ctx context.Context) {
|
||
|
|
||
|
}
|