mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Run go fmt
This commit is contained in:
parent
17b37ab2ed
commit
58bd38befd
@ -5,7 +5,6 @@ import(
|
|||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type AdminListener struct {
|
type AdminListener struct {
|
||||||
connChan chan (net.Conn)
|
connChan chan (net.Conn)
|
||||||
}
|
}
|
||||||
|
13
auth.go
13
auth.go
@ -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++ {
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1
main.go
1
main.go
@ -4,7 +4,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Println("Starting up")
|
log.Println("Starting up")
|
||||||
|
|
||||||
|
@ -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"`
|
||||||
}
|
}
|
||||||
|
6
utils.go
6
utils.go
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user