Skip to content

Commit

Permalink
Merge pull request #488 from anandrgitnirman/master
Browse files Browse the repository at this point in the history
#487 :set passthrough_enabled = true by default
  • Loading branch information
anandrgitnirman authored Apr 8, 2020
2 parents 4b7f35f + 8658a08 commit 066df2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ metadata][service-configuration-metadata].
Id of the service to search for [service configuration
metadata][service-configuration-metadata].

* **passthrough_enabled** (optional; default: `false`) -
* **passthrough_enabled** (optional; default: `true`) -
when passthrough is disabled, daemon echoes requests back as responses; `false`
reserved mostly for testing purposes.

* **passthrough_endpoint** (required if `service_type` != `executable`) -
endpoint to which requests should be proxied for handling by service.
This config is mandatory when `passthrough_enabled` is set to true.
and needs to be a valid url

* **executable_path** (required if `service_type` == `executable`) -
path to executable to expose as a service.
Expand Down
8 changes: 5 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const (
"max_message_size_in_mb" : 4,
"metering_enabled": false,
"organization_id": "ExampleOrganizationId",
"passthrough_enabled": false,
"passthrough_enabled": true,
"service_id": "ExampleServiceId",
"private_key": "",
"ssl_cert": "",
Expand Down Expand Up @@ -307,9 +307,10 @@ func ValidateEmail(email string) bool {
}

func ValidateEndpoints(daemonEndpoint string, passthroughEndpoint string) error {

passthroughURL, err := url.Parse(passthroughEndpoint)
if err != nil {
return errors.New("passthrough endpoint must be a valid URL")
if err != nil || passthroughURL.Host == "" {
return errors.New("passthrough_endpoint is the endpoint of your AI service in the daemon config and needs to be a valid url.")
}
daemonHost, daemonPort, err := net.SplitHostPort(daemonEndpoint)
if err != nil {
Expand All @@ -332,6 +333,7 @@ var userAddress []common.Address

func IsAllowedUser(address *common.Address) bool {
for _, user := range userAddress {
log.Println("userAddressFromConfig:" + user.Hex() + "<>" + address.Hex())
if user == *address {
return true
}
Expand Down
2 changes: 2 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func TestValidateEndpoints(t *testing.T) {
assert.Equal(t, nil, err)
err = ValidateEndpoints("1.2.3.4:8080", "http://127.0.0.1:8080")
assert.Equal(t, nil, err)
err = ValidateEndpoints("1.2.3.4:8080", "")
assert.Equal(t, "passthrough_endpoint is the endpoint of your AI service in the daemon config and needs to be a valid url.", err.Error())
}

func TestAllowedUserChecks(t *testing.T) {
Expand Down

0 comments on commit 066df2a

Please sign in to comment.