-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple domain names (#153)
* Introduce support for multiple domain names * Use latest iprose version * Remove obsoleted comment * Fix typo * Fix response when no way to get hostname * Remove explicit ciphers initialization
- Loading branch information
1 parent
b29a7de
commit 20e682c
Showing
11 changed files
with
375 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package xhttp | ||
|
||
import ( | ||
adminAPI "github.com/vpnhouse/api/go/server/tunnel_admin" | ||
"github.com/vpnhouse/tunnel/pkg/xerror" | ||
) | ||
|
||
// DomainConfig is the YAML version of the `adminAPI.DomainConfig` struct. | ||
type DomainConfig struct { | ||
Mode string `yaml:"mode" valid:"required"` | ||
PrimaryName string `yaml:"name" valid:"dns,required"` | ||
ExtraNames []string `yaml:"extra_names,omitempty" valid:"dns"` | ||
IssueSSL bool `yaml:"issue_ssl,omitempty"` | ||
Schema string `yaml:"schema,omitempty"` | ||
Email string `yaml:"email,omitempty" valid:"email"` | ||
|
||
// Dir to store cached certificates, use sub-directory of cfgDir if possible. | ||
Dir string `yaml:"dir,omitempty" valid:"path"` | ||
} | ||
|
||
func (c *DomainConfig) Validate() error { | ||
modes := map[string]struct{}{ | ||
string(adminAPI.DomainConfigModeReverseProxy): {}, | ||
string(adminAPI.DomainConfigModeDirect): {}, | ||
} | ||
schemas := map[string]struct{}{ | ||
"http": {}, | ||
"https": {}, | ||
} | ||
|
||
if len(c.PrimaryName) == 0 { | ||
return xerror.EInternalError("domain.name is required", nil) | ||
} | ||
if len(c.Mode) == 0 { | ||
return xerror.EInternalError("domain.mode is required", nil) | ||
} | ||
if _, ok := modes[c.Mode]; !ok { | ||
return xerror.EInternalError("domain.mode got unknown value, expecting `direct` or `reverse-proxy`", nil) | ||
} | ||
|
||
if c.Mode == string(adminAPI.DomainConfigModeReverseProxy) { | ||
if len(c.Schema) == 0 { | ||
return xerror.EInternalError("domain.schema is required for the reverse-proxy mode", nil) | ||
} | ||
if _, ok := schemas[c.Schema]; !ok { | ||
return xerror.EInternalError("domain.schema got unknown value, expecting `http` or `https`", nil) | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.