Run go fmt

This commit is contained in:
Anders Pitman 2020-09-29 20:12:54 -06:00
parent 17b37ab2ed
commit 58bd38befd
6 changed files with 388 additions and 399 deletions

View File

@ -1,17 +1,16 @@
package main package main
import( import (
"fmt" "fmt"
"net" "net"
) )
type AdminListener struct { type AdminListener struct {
connChan chan(net.Conn) connChan chan (net.Conn)
} }
func NewAdminListener() *AdminListener { func NewAdminListener() *AdminListener {
connChan := make(chan(net.Conn)) connChan := make(chan (net.Conn))
return &AdminListener{connChan} return &AdminListener{connChan}
} }

13
auth.go
View File

@ -1,19 +1,18 @@
package main package main
import ( import (
"log"
"fmt"
"errors"
"crypto/rand" "crypto/rand"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"math/big" "math/big"
"net/smtp" "net/smtp"
"sync" "sync"
"time" "time"
"io/ioutil"
"encoding/json"
) )
type Auth struct { type Auth struct {
pendingRequests map[string]chan struct{} pendingRequests map[string]chan struct{}
sessions map[string]*Session sessions map[string]*Session
@ -141,8 +140,8 @@ func (a *Auth) Verify(key string) error {
return nil return nil
} }
const chars string = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
const chars string = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
func genRandomKey() (string, error) { func genRandomKey() (string, error) {
id := "" id := ""
for i := 0; i < 32; i++ { for i := 0; i < 32; i++ {

View File

@ -1,20 +1,19 @@
package main package main
import ( import (
"crypto/tls"
"encoding/json"
"fmt" "fmt"
"github.com/caddyserver/certmagic"
"io"
"io/ioutil"
"log" "log"
"net" "net"
"net/http" "net/http"
"crypto/tls"
"io"
"sync"
"strconv" "strconv"
"encoding/json" "sync"
"io/ioutil"
"github.com/caddyserver/certmagic"
) )
type BoringProxyConfig struct { type BoringProxyConfig struct {
AdminDomain string `json:"admin_domain"` AdminDomain string `json:"admin_domain"`
Smtp *SmtpConfig `json:"smtp"` Smtp *SmtpConfig `json:"smtp"`
@ -27,7 +26,6 @@ type SmtpConfig struct {
Password string Password string
} }
type BoringProxy struct { type BoringProxy struct {
config *BoringProxyConfig config *BoringProxyConfig
auth *Auth auth *Auth
@ -67,7 +65,6 @@ func NewBoringProxy() *BoringProxy {
auth := NewAuth() auth := NewAuth()
p := &BoringProxy{config, auth, tunMan, adminListener, certConfig} p := &BoringProxy{config, auth, tunMan, adminListener, certConfig}
http.HandleFunc("/", p.handleAdminRequest) http.HandleFunc("/", p.handleAdminRequest)
@ -296,5 +293,3 @@ func (p *BoringProxy) handleTunnelConnection(decryptedConn net.Conn, serverName
wg.Wait() wg.Wait()
} }

View File

@ -4,7 +4,6 @@ import (
"log" "log"
) )
func main() { func main() {
log.Println("Starting up") log.Println("Starting up")

View File

@ -1,15 +1,14 @@
package main package main
import ( import (
"log"
"errors"
"sync"
"encoding/json" "encoding/json"
"io/ioutil" "errors"
"github.com/caddyserver/certmagic" "github.com/caddyserver/certmagic"
"io/ioutil"
"log"
"sync"
) )
type Tunnel struct { type Tunnel struct {
Port int `json:"port"` Port int `json:"port"`
} }

View File

@ -1,14 +1,13 @@
package main package main
import ( import (
"encoding/json"
"errors"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"errors"
"strings" "strings"
"encoding/json"
) )
func saveJson(data interface{}, filePath string) error { func saveJson(data interface{}, filePath string) error {
jsonStr, err := json.MarshalIndent(data, "", " ") jsonStr, err := json.MarshalIndent(data, "", " ")
if err != nil { if err != nil {
@ -22,7 +21,6 @@ func saveJson(data interface{}, filePath string) error {
return nil return nil
} }
// Looks for auth token in cookie, then header, then query string // Looks for auth token in cookie, then header, then query string
func extractToken(tokenName string, r *http.Request) (string, error) { func extractToken(tokenName string, r *http.Request) (string, error) {
tokenCookie, err := r.Cookie(tokenName) tokenCookie, err := r.Cookie(tokenName)