make admin domain more configurable

This commit is contained in:
AJ ONeal 2020-04-28 01:16:16 -06:00
parent 880da4d685
commit b8a7c9e481
5 changed files with 17 additions and 5 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
lumberjack "gopkg.in/natefinch/lumberjack.v2" lumberjack "gopkg.in/natefinch/lumberjack.v2"
telebit "git.coolaj86.com/coolaj86/go-telebitd"
"git.coolaj86.com/coolaj86/go-telebitd/rvpn/server" "git.coolaj86.com/coolaj86/go-telebitd/rvpn/server"
) )
@ -34,7 +35,7 @@ var (
connectionTable *server.Table connectionTable *server.Table
secretKey = "abc123" secretKey = "abc123"
wssHostName = "localhost.rootprojects.org" wssHostName = "localhost.rootprojects.org"
adminHostName = "rvpn.rootprojects.invalid" adminHostName = telebit.InvalidAdminDomain
idle int idle int
dwell int dwell int
cancelcheck int cancelcheck int

View File

@ -9,6 +9,7 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
telebit "git.coolaj86.com/coolaj86/go-telebitd"
"git.coolaj86.com/coolaj86/go-telebitd/rvpn/envelope" "git.coolaj86.com/coolaj86/go-telebitd/rvpn/envelope"
) )
@ -40,7 +41,7 @@ func handleAdminClient(ctx context.Context, oneConn *oneConnListener) {
switch url := r.URL.Path; url { switch url := r.URL.Path; url {
case "/": case "/":
// check to see if we are using the administrative Host // check to see if we are using the administrative Host
if strings.Contains(r.Host, "rvpn.rootprojects.invalid") { if strings.Contains(r.Host, telebit.InvalidAdminDomain) {
http.Redirect(w, r, "/admin", 301) http.Redirect(w, r, "/admin", 301)
serverStatus.AdminStats.IncResponses() serverStatus.AdminStats.IncResponses()

View File

@ -17,6 +17,7 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
telebit "git.coolaj86.com/coolaj86/go-telebitd"
"git.coolaj86.com/coolaj86/go-telebitd/rvpn/packer" "git.coolaj86.com/coolaj86/go-telebitd/rvpn/packer"
"git.coolaj86.com/coolaj86/go-telebitd/rvpn/sni" "git.coolaj86.com/coolaj86/go-telebitd/rvpn/sni"
) )
@ -233,11 +234,11 @@ func handleStream(ctx context.Context, wConn *WedgeConn) {
if bytes.Contains(peek[:], []byte{0x0d, 0x0a}) { if bytes.Contains(peek[:], []byte{0x0d, 0x0a}) {
//string protocol //string protocol
if bytes.ContainsAny(peek[:], "HTTP/") { if bytes.ContainsAny(peek[:], "HTTP/") {
loginfo.Println("identifed HTTP") loginfo.Println("identified HTTP")
r, err := http.ReadRequest(bufio.NewReader(bytes.NewReader(peek))) r, err := http.ReadRequest(bufio.NewReader(bytes.NewReader(peek)))
if err != nil { if err != nil {
loginfo.Println("identifed as HTTP, failed request parsing", err) loginfo.Println("identified as HTTP, failed request parsing", err)
return return
} }
@ -255,7 +256,7 @@ func handleStream(ctx context.Context, wConn *WedgeConn) {
//do we have a invalid domain indicating Admin? //do we have a invalid domain indicating Admin?
//if yes, prep the oneConn and send it to the handler //if yes, prep the oneConn and send it to the handler
} else if strings.Contains(r.Host, "rvpn.rootprojects.invalid") { } else if strings.Contains(r.Host, telebit.InvalidAdminDomain) {
loginfo.Println("admin") loginfo.Println("admin")
oneConn := &oneConnListener{wConn} oneConn := &oneConnListener{wConn}
handleAdminClient(ctx, oneConn) handleAdminClient(ctx, oneConn)

5
telebit.go Normal file
View File

@ -0,0 +1,5 @@
package telebit
// InvalidAdminDomain is a domain that can only be accessed by Domain Fronting
// (i.e. trixy clients sending fake headers), not browsers
var InvalidAdminDomain = "rvpn.rootprojects.invalid"

4
tools/tools.go Normal file
View File

@ -0,0 +1,4 @@
//+build tools
// tools is a faux package for tracking dependencies that don't make it into the code
package tools