Skip to content

Commit

Permalink
Update auth and radar endpoints (digitalocean#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
miroswan authored Jun 23, 2020
1 parent 21538af commit 963ab95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ $(deb_package): $(base_package)
# print information about the compiled deb package
@docker run --rm -i -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" ubuntu:xenial /bin/bash -c 'dpkg --info $@ && dpkg -c $@'

.PHONY: install_deb
install_deb: deb
@dpkg -i $(deb_package)

rpm: $(rpm_package)
$(rpm_package): $(base_package)
Expand Down
7 changes: 5 additions & 2 deletions cmd/do-agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ var (
disabledCollectors = map[string]interface{}{}
)

const internalProxyURL = "http://169.254.169.254"

const (
defaultMetadataURL = "http://169.254.169.254/metadata"
defaultAuthURL = "https://sonar.digitalocean.com"
defaultAuthURL = internalProxyURL
defaultSonarURL = ""
defaultTimeout = 2 * time.Second
defaultWebListenAddress = "127.0.0.1:9100"
)

var defaultMetadataURL = fmt.Sprintf("%s/metadata", internalProxyURL)

func init() {
kingpin.CommandLine.Name = "do-agent"

Expand Down
7 changes: 4 additions & 3 deletions pkg/clients/tsclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
userAgentHeader = "User-Agent"
authKeyHeader = "X-Auth-Key"
contentTypeHeader = "Content-Type"
internalProxyURL = "http://169.254.169.254"

defaultWaitIntervalSeconds = 60
defaultMaxBatchSize = 1000
Expand Down Expand Up @@ -175,8 +176,8 @@ func New(opts ...ClientOptFn) Client {
opt := &ClientOptions{
UserAgent: "tsclient-unknown",
Timeout: 10 * time.Second,
MetadataEndpoint: "http://169.254.169.254/metadata",
RadarEndpoint: "https://sonar.digitalocean.com",
MetadataEndpoint: fmt.Sprintf("%s/metadata", internalProxyURL),
RadarEndpoint: internalProxyURL,
}

for _, fn := range opts {
Expand Down Expand Up @@ -289,7 +290,7 @@ func (c *HTTPClient) url() string {
return fmt.Sprintf("%s/v1/metrics/trusted/%s", endpoint, c.appName)
}

endpoint := fmt.Sprintf("https://%s.sonar.digitalocean.com", c.region)
endpoint := internalProxyURL
if len(c.wharfEndpoints) > 0 {
endpoint = c.wharfEndpoints[rand.Intn(len(c.wharfEndpoints))]
}
Expand Down

0 comments on commit 963ab95

Please sign in to comment.