add enough to support libvirt Spice
This commit is contained in:
parent
c3e8971e30
commit
c325f87217
38
event.proto
38
event.proto
|
@ -4,17 +4,33 @@ package gus;
|
||||||
|
|
||||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||||
|
|
||||||
message Event {
|
enum GusEventType {
|
||||||
string hostname = 1; // the hostname of the client
|
Connect = 0; // a socket connect attempt
|
||||||
string address = 2; // the IP address from the client
|
Disconnect = 1; // a socket closed
|
||||||
string where = 3; // where gus was sending the client traffic
|
Enable = 2; // listening on a port was enabled
|
||||||
google.protobuf.Timestamp ctime = 4; // when the socket opened
|
Disable = 3; // listening on a port was disabled
|
||||||
google.protobuf.Timestamp etime = 5; // when the socket ended
|
|
||||||
int64 localPort = 6; // the port gus was listening on
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message Events { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:nomutex`
|
message GusSocket {
|
||||||
string uuid = 1; // `autogenpb:uuid:4e91f9e6-f545-4c72-bec4-ab951276da1d`
|
string srcHostname = 1; // the hostname
|
||||||
string version = 2; // `autogenpb:version:v0.0.1`
|
string srcIp = 2; // the IPv4 or IPv6 address
|
||||||
repeated Event events = 3;
|
string srcPort = 3; // the port
|
||||||
|
string destHostname = 4; // the hostname
|
||||||
|
string destIp = 5; // the IPv4 or IPv6 address
|
||||||
|
string destPort = 6; // the port
|
||||||
|
}
|
||||||
|
|
||||||
|
message Event {
|
||||||
|
string Hostname = 1; // the hostname
|
||||||
|
int64 localPort = 2; // the port gus was listening on
|
||||||
|
GusEventType etype = 3; // what kind of event was this
|
||||||
|
GusSocket sock = 4; // socket details if event needs them
|
||||||
|
google.protobuf.Timestamp ctime = 5; // event create time
|
||||||
|
google.protobuf.Timestamp etime = 6; // event end time
|
||||||
|
}
|
||||||
|
|
||||||
|
message Events { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:nomutex`
|
||||||
|
string uuid = 1; // `autogenpb:uuid:4e91f9e6-f545-4c72-bec4-ab951276da1d`
|
||||||
|
string version = 2; // `autogenpb:version:v0.0.1`
|
||||||
|
repeated Event events = 3;
|
||||||
}
|
}
|
||||||
|
|
16
http.go
16
http.go
|
@ -25,6 +25,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// domname := r.URL.Query().Get("domain")
|
// domname := r.URL.Query().Get("domain")
|
||||||
flag := r.URL.Query().Get("flag")
|
flag := r.URL.Query().Get("flag")
|
||||||
|
port := r.URL.Query().Get("port")
|
||||||
|
dest := r.URL.Query().Get("dest")
|
||||||
|
|
||||||
msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
|
msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -66,6 +68,20 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if route == "/enable" {
|
||||||
|
log.HttpMode(w)
|
||||||
|
defer log.HttpMode(nil)
|
||||||
|
log.Info("enable port/dest", port, dest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if route == "/disable" {
|
||||||
|
log.HttpMode(w)
|
||||||
|
defer log.HttpMode(nil)
|
||||||
|
log.Info("enable port/dest", port, dest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// toggle logging flags
|
// toggle logging flags
|
||||||
if route == "/flag" {
|
if route == "/flag" {
|
||||||
log.HttpMode(w)
|
log.HttpMode(w)
|
||||||
|
|
6
main.go
6
main.go
|
@ -121,9 +121,11 @@ func handleConnection(clientConn net.Conn, where string, localport int) {
|
||||||
// make a new event from this new connection
|
// make a new event from this new connection
|
||||||
log.Printf("Connected on port %d from client: %s to where = %s\n", localport, clientConn.RemoteAddr(), where)
|
log.Printf("Connected on port %d from client: %s to where = %s\n", localport, clientConn.RemoteAddr(), where)
|
||||||
e := new(Event)
|
e := new(Event)
|
||||||
e.Address = fmt.Sprintf("%s\n", clientConn.RemoteAddr())
|
e.Etype = GusEventType_Connect
|
||||||
e.Where = where
|
|
||||||
e.LocalPort = int64(localport)
|
e.LocalPort = int64(localport)
|
||||||
|
e.Sock = new(GusSocket)
|
||||||
|
e.Sock.SrcIp = fmt.Sprintf("%s", clientConn.RemoteAddr())
|
||||||
|
e.Sock.DestIp = where
|
||||||
e.Ctime = timestamppb.New(time.Now())
|
e.Ctime = timestamppb.New(time.Now())
|
||||||
me.events.Append(e)
|
me.events.Append(e)
|
||||||
me.eventsChanged = true
|
me.eventsChanged = true
|
||||||
|
|
|
@ -4,9 +4,12 @@ package gus;
|
||||||
|
|
||||||
message Portmap {
|
message Portmap {
|
||||||
int64 listen = 1; // `autogenpb:unique`
|
int64 listen = 1; // `autogenpb:unique`
|
||||||
string connect = 2; // `autogenpb:unique`
|
string connect = 2;
|
||||||
bool enabled = 3;
|
bool enabled = 3;
|
||||||
bool allowIPv4 = 4;
|
bool allowIPv4 = 4;
|
||||||
|
bool useME = 5;
|
||||||
|
string hosts = 6;
|
||||||
|
string iptables = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Portmaps { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:nomutex`
|
message Portmaps { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:nomutex`
|
||||||
|
|
|
@ -55,7 +55,7 @@ func makeEventsWin() {
|
||||||
all := me.events.All()
|
all := me.events.All()
|
||||||
for all.Scan() {
|
for all.Scan() {
|
||||||
e := all.Next()
|
e := all.Next()
|
||||||
if strings.HasPrefix(e.Address, "192.168") {
|
if strings.HasPrefix(e.Sock.SrcIp, "192.168") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
found.Append(e)
|
found.Append(e)
|
||||||
|
@ -114,8 +114,18 @@ func AddEventsPB(tbox *gui.Node, pb *Events) *EventsTable {
|
||||||
t.AddStringFunc("etime", etimef)
|
t.AddStringFunc("etime", etimef)
|
||||||
|
|
||||||
t.AddHostname()
|
t.AddHostname()
|
||||||
t.AddAddress()
|
t.AddStringFunc("src ip", func(e *Event) string {
|
||||||
t.AddWhere()
|
if e.Sock != nil {
|
||||||
|
return e.Sock.SrcIp
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
})
|
||||||
|
t.AddStringFunc("dest ip", func(e *Event) string {
|
||||||
|
if e.Sock != nil {
|
||||||
|
return e.Sock.DestIp
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
})
|
||||||
t.AddLocalPort()
|
t.AddLocalPort()
|
||||||
t.ShowTable()
|
t.ShowTable()
|
||||||
return t
|
return t
|
||||||
|
|
Loading…
Reference in New Issue