-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support automatic discovery of IPs from AWS metadata (#3)
* refactor server creation * feat: dynamic start/stop from aws * only log errors starting server * fix: various improvements
- Loading branch information
1 parent
e988e2b
commit b92e9f8
Showing
8 changed files
with
323 additions
and
111 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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
package lib | ||
|
||
import ( | ||
"net/netip" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAfterOneIpBlock(t *testing.T) { | ||
ip1 := netip.AddrFrom4([4]byte{192, 168, 1, 0}) | ||
ip2 := netip.AddrFrom4([4]byte{192, 168, 2, 0}) | ||
assert.Equal(t, AfterCountIpBlock(ip1, 24, 1), ip2, "next ip mismatch") | ||
|
||
ip2 = netip.AddrFrom4([4]byte{192, 168, 1, 16}) | ||
assert.Equal(t, AfterCountIpBlock(ip1, 28, 1), ip2, "next ip mismatch") | ||
|
||
ip2 = netip.AddrFrom4([4]byte{193, 168, 1, 0}) | ||
assert.Equal(t, AfterCountIpBlock(ip1, 8, 1), ip2, "next ip mismatch") | ||
} | ||
|
||
func TestAfterCountIpBlock(t *testing.T) { | ||
ip1 := netip.AddrFrom4([4]byte{192, 168, 1, 0}) | ||
ip2 := netip.AddrFrom4([4]byte{192, 168, 6, 0}) | ||
assert.Equal(t, AfterCountIpBlock(ip1, 24, 5), ip2) | ||
|
||
ip2 = netip.AddrFrom4([4]byte{192, 168, 1, 64}) | ||
assert.Equal(t, AfterCountIpBlock(ip1, 28, 4), ip2) | ||
|
||
ip2 = netip.AddrFrom4([4]byte{192, 168, 2, 128}) | ||
assert.Equal(t, AfterCountIpBlock(ip1, 25, 3), ip2) | ||
} |
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
Oops, something went wrong.