mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Merge branch 'master' into oauth2
This commit is contained in:
@@ -47,6 +47,7 @@ func Listen() {
|
||||
flagSet := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
|
||||
newAdminDomain := flagSet.String("admin-domain", "", "Admin Domain")
|
||||
sshServerPort := flagSet.Int("ssh-server-port", 22, "SSH Server Port")
|
||||
dbDir := flagSet.String("db-dir", "", "Database file directory")
|
||||
certDir := flagSet.String("cert-dir", "", "TLS cert directory")
|
||||
printLogin := flagSet.Bool("print-login", false, "Prints admin login information")
|
||||
httpPort := flagSet.Int("http-port", 80, "HTTP (insecure) port")
|
||||
@@ -54,6 +55,7 @@ func Listen() {
|
||||
allowHttp := flagSet.Bool("allow-http", false, "Allow unencrypted (HTTP) requests")
|
||||
publicIp := flagSet.String("public-ip", "", "Public IP")
|
||||
behindProxy := flagSet.Bool("behind-proxy", false, "Whether we're running behind another reverse proxy")
|
||||
acmeEmail := flagSet.String("acme-email", "", "Email for ACME (ie Let's Encrypt)")
|
||||
acmeUseStaging := flagSet.Bool("acme-use-staging", false, "Use ACME (ie Let's Encrypt) staging servers")
|
||||
err := flagSet.Parse(os.Args[2:])
|
||||
if err != nil {
|
||||
@@ -62,7 +64,7 @@ func Listen() {
|
||||
|
||||
log.Println("Starting up")
|
||||
|
||||
db, err := NewDatabase()
|
||||
db, err := NewDatabase(*dbDir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -104,6 +106,10 @@ func Listen() {
|
||||
//certmagic.DefaultACME.DisableHTTPChallenge = true
|
||||
//certmagic.DefaultACME.DisableTLSALPNChallenge = true
|
||||
|
||||
if *acmeEmail != "" {
|
||||
certmagic.DefaultACME.Email = *acmeEmail
|
||||
}
|
||||
|
||||
if *acmeUseStaging {
|
||||
certmagic.DefaultACME.CA = certmagic.LetsEncryptStagingCA
|
||||
}
|
||||
|
||||
12
database.go
12
database.go
@@ -10,6 +10,8 @@ import (
|
||||
"github.com/takingnames/namedrop-go"
|
||||
)
|
||||
|
||||
var DBFolderPath string
|
||||
|
||||
type Database struct {
|
||||
AdminDomain string `json:"admin_domain"`
|
||||
Tokens map[string]TokenData `json:"tokens"`
|
||||
@@ -60,11 +62,13 @@ type Tunnel struct {
|
||||
AuthPassword string `json:"auth_password"`
|
||||
}
|
||||
|
||||
func NewDatabase() (*Database, error) {
|
||||
func NewDatabase(path string) (*Database, error) {
|
||||
|
||||
dbJson, err := ioutil.ReadFile("boringproxy_db.json")
|
||||
DBFolderPath = path
|
||||
|
||||
dbJson, err := ioutil.ReadFile(DBFolderPath + "boringproxy_db.json")
|
||||
if err != nil {
|
||||
log.Println("failed reading boringproxy_db.json")
|
||||
log.Printf("failed reading %sboringproxy_db.json\n", DBFolderPath)
|
||||
dbJson = []byte("{}")
|
||||
}
|
||||
|
||||
@@ -319,5 +323,5 @@ func (d *Database) DeleteUser(username string) {
|
||||
}
|
||||
|
||||
func (d *Database) persist() {
|
||||
saveJson(d, "boringproxy_db.json")
|
||||
saveJson(d, DBFolderPath+"boringproxy_db.json")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user