-
Notifications
You must be signed in to change notification settings - Fork 76
Add option to serve index provider ads over http #1452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f975d58
feat: option to serve index provider ads over http
dirkmc 25d9f0d
fix: config naming, hostname parsing
dirkmc fbe12c9
fix: update docsgen
dirkmc 675743f
fix: log announce address
dirkmc 1a37b06
feat: add config for indexer direct announce urls
dirkmc 2d16620
refactor: always announce over pubsub
dirkmc 13f9521
fix: docsgen
dirkmc 331879f
test: add test case for empty announce address hostname
dirkmc bc44a4b
Add `boostd index announce-latest` command (#1456)
dirkmc f90b5ea
feat: update to index-provider v0.11.2
dirkmc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| package util | ||
|
|
||
| import ( | ||
| "fmt" | ||
| ma "github.com/multiformats/go-multiaddr" | ||
| "net" | ||
| "strings" | ||
| ) | ||
|
|
||
| func ToHttpMultiaddr(hostname string, port int) (ma.Multiaddr, error) { | ||
| var saddr string | ||
| if n := net.ParseIP(hostname); n != nil { | ||
| ipVersion := "ip4" | ||
| if strings.Contains(hostname, ":") { | ||
| ipVersion = "ip6" | ||
| } | ||
| saddr = fmt.Sprintf("/%s/%s/tcp/%d/http", ipVersion, hostname, port) | ||
| } else { | ||
| saddr = fmt.Sprintf("/dns/%s/tcp/%d/http", hostname, port) | ||
| } | ||
| return ma.NewMultiaddr(saddr) | ||
| } |
This file contains hidden or 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,34 @@ | ||
| package util | ||
|
|
||
| import ( | ||
| "github.com/stretchr/testify/require" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestToHttpMultiaddr(t *testing.T) { | ||
| tcs := []struct { | ||
| hostname string | ||
| port int | ||
| expected string | ||
| }{{ | ||
| hostname: "192.168.1.1", | ||
| port: 1234, | ||
| expected: "/ip4/192.168.1.1/tcp/1234/http", | ||
| }, { | ||
| hostname: "2001:db8::68", | ||
| port: 1234, | ||
| expected: "/ip6/2001:db8::68/tcp/1234/http", | ||
| }, { | ||
| hostname: "example.com", | ||
| port: 1234, | ||
| expected: "/dns/example.com/tcp/1234/http", | ||
| }} | ||
|
|
||
| for _, tc := range tcs { | ||
| t.Run("", func(t *testing.T) { | ||
| ma, err := ToHttpMultiaddr(tc.hostname, tc.port) | ||
| require.NoError(t, err) | ||
| require.Equal(t, tc.expected, ma.String()) | ||
| }) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.