Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a1164027dc | |||
| dd9447d771 | |||
| 524753be2a | |||
| 593f88e2a3 | |||
|
f0c09c2176
|
|||
| f9462d3e0b | |||
| c20bd3d41f | |||
| f0cef6c19f | |||
| 05538e6925 | |||
| 0c21d74c15 | |||
| 401603f4be |
@@ -0,0 +1,51 @@
|
||||
export CLOUDFLARE_DNS_API_TOKEN=wFpklBgp0Z1A4yDs5zNhlTKne3W2Si8GLwkl10Oz
|
||||
|
||||
if [ -n "$JPICTL" ]; then
|
||||
:
|
||||
elif JPICTL=$(which jpictl); then
|
||||
echo 2 >&2
|
||||
elif [ -d ./cmd/jpictl ]; then
|
||||
JPICTL="go run ./cmd/jpictl/"
|
||||
if [ -d "$(go env GOBIN)" ]; then
|
||||
echo 3a >&2
|
||||
elif [ -d "$(go env GOPATH)" ]; then
|
||||
export GOBIN="$(go env GOPATH)/bin"
|
||||
echo 3b >&2
|
||||
elif WS=$(x --root); then
|
||||
export GOBIN="$WS/bin"
|
||||
unset -v WS
|
||||
echo 3c >&2
|
||||
else
|
||||
echo 3d >&2
|
||||
fi
|
||||
elif [ -d "${WS:-}" -a -x "${WS:+$WS/bin/jpictl}" ]; then
|
||||
JPICTL="$WS/bin/jpictl"
|
||||
export PATH="$WS/bin:$PATH"
|
||||
echo "4a" >&2
|
||||
else
|
||||
for WS in \
|
||||
"$(x --root)" \
|
||||
"$HOME/projects/apptly" \
|
||||
; do
|
||||
if [ -x "$WS/bin/jpictl" ]; then
|
||||
JPICTL="$WS/bin/jpictl"
|
||||
export PATH="$WS/bin:$PATH"
|
||||
echo "4b: '$WS'" >&2
|
||||
break
|
||||
fi
|
||||
done
|
||||
unset -v WS
|
||||
|
||||
[ -n "$JPICTL" ] || echo "4c" >&2
|
||||
fi
|
||||
|
||||
if [ -n "$JPICTL" ]; then
|
||||
echo "JPICTL='$JPICTL'" >&2
|
||||
|
||||
export JPICTL
|
||||
jpictl() {
|
||||
$JPICTL "$@"
|
||||
}
|
||||
else
|
||||
echo "JPICTL="
|
||||
fi
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "write",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "cmd/jpictl",
|
||||
"args": [ "write" ],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"name": "dump",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "cmd/jpictl",
|
||||
"args": [ "dump", "-vvvv" ],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"name": "env",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "cmd/jpictl",
|
||||
"args": [ "env", "-vvvv" ],
|
||||
"cwd": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
dir: m
|
||||
name: m
|
||||
domain: jpi.cloud
|
||||
ceph_fsid: 28180b9b-6d5d-4be0-bb5b-e4b04bf03804
|
||||
regions:
|
||||
- name: de
|
||||
- name: eu
|
||||
id: 1
|
||||
cluster: ""
|
||||
regions:
|
||||
- de
|
||||
- nl
|
||||
- name: nl
|
||||
- name: uk
|
||||
id: 2
|
||||
cluster: ""
|
||||
- name: us
|
||||
id: 3
|
||||
cluster: ""
|
||||
- name: europe
|
||||
regions:
|
||||
- eu
|
||||
- uk
|
||||
- name: global
|
||||
regions:
|
||||
- europe
|
||||
- us
|
||||
zones:
|
||||
- id: 1
|
||||
name: ssd-lon
|
||||
regions:
|
||||
- uk
|
||||
machines:
|
||||
- id: 3
|
||||
public:
|
||||
- 63.250.53.5
|
||||
- 2602:ff16:7:0:1:66:0:1
|
||||
rings:
|
||||
- ring: 0
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: WJY1yrd14c0gY4qqq1O8BPck46TVYebXrT+OoMbEqG8=
|
||||
publickey: aDXNwapVjufcuQKfBN+waJObe1TaeeaSNl1suA0u+00=
|
||||
- ring: 1
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: 2CDO+x8HVKfw1/iqC2WkwIEQyWZsC9XPW1otqxarR0o=
|
||||
publickey: untmMfW2W4OiMgG/6nAysoivXtDh7cZ9/rxhgJ4OlC4=
|
||||
- id: 7
|
||||
ceph_monitor: true
|
||||
public:
|
||||
- 107.155.122.3
|
||||
- 2602:ff16:7:0:1:6d:0:1
|
||||
rings:
|
||||
- ring: 1
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: iN4Rc3J36APlkIP/ksSpHIwAuxC/ehYLwGQ5va1AhG8=
|
||||
publickey: XGVXDmxQajHpsgpzgrp+r/ZWxZUaodTpvGBJuLlZ0n4=
|
||||
- id: 2
|
||||
name: ssd-ams
|
||||
regions:
|
||||
- nl
|
||||
machines:
|
||||
- id: 3
|
||||
public:
|
||||
- 89.233.107.128
|
||||
- 2602:ff16:9:0:1:1a7:0:1
|
||||
rings:
|
||||
- ring: 0
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: oHVQY976pFH1lAhCrz9c40vR/e5PIXw7ZXv6pU6A5Ho=
|
||||
publickey: y/Gkid2Mjxo1WO9Zi7mh+DETNYKT/AAc3K3bvr9xp3c=
|
||||
- ring: 1
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: 6I/ZMxaWUTbNc+SIGkNKxgovONqv6EAvg7NeeTRrR1c=
|
||||
publickey: 9i0XI358OOYYoxoxV5lX8siqE8uiEwCsuWLo6LoFu0Y=
|
||||
- id: 4
|
||||
ceph_monitor: true
|
||||
public:
|
||||
- 89.233.107.251
|
||||
- 2602:ff16:9:0:1:130:0:1
|
||||
rings:
|
||||
- ring: 1
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: SPBd5Ka29ZecKYy7BW85rW7FO9dwKwoUHlSibybPG1s=
|
||||
publickey: QpJupYlnJc7wc3+gAlEmbFMonsqpVnYRy7f/gnPqqBw=
|
||||
- id: 5
|
||||
inactive: true
|
||||
public:
|
||||
- 89.233.107.107
|
||||
- 2602:ff16:9:0:1:74:0:1
|
||||
rings:
|
||||
- ring: 1
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: mJaFvu9TBwE2i0rjhfhvpB3xZmp++3BVwa7QAvWXImY=
|
||||
publickey: HDLVEwLv0uugyZ9C1C9ZWuiaWQ1qIqqe/DAUxYI0whM=
|
||||
- id: 3
|
||||
name: htz-fsn
|
||||
regions:
|
||||
- de
|
||||
machines:
|
||||
- id: 1
|
||||
ceph_monitor: true
|
||||
public:
|
||||
- 157.90.209.125
|
||||
- 2a01:4f8:252:168f::2
|
||||
rings:
|
||||
- ring: 0
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: AMz/pCgOMVh1/2rT9uCFMox+LQgH5FrE4xUeqSs0x0M=
|
||||
publickey: K9LYog8vtRFN4nW6dJWMQ9trmRrYuLpbu/Ze5kIiBGw=
|
||||
- ring: 1
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: 2JpA1G0Dp+sEuDhKnzToz0h76o2iLP+S7Qb9itlgXVA=
|
||||
publickey: qWmYfgeRAQ563gWLdeYs65XjGJTSE+W8WTbpLZ0e1CQ=
|
||||
- id: 4
|
||||
name: ssd-nyc
|
||||
regions:
|
||||
- us
|
||||
machines:
|
||||
- id: 3
|
||||
inactive: true
|
||||
ceph_monitor: true
|
||||
public:
|
||||
- 208.87.134.41
|
||||
- 2602:ff16:3:0:1:4fa:0:1
|
||||
rings:
|
||||
- ring: 0
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: YNDxj+QSO3p5pXw9h7lBx0cLM0kJDv3v7BYLfc8TR3I=
|
||||
publickey: 1UFgleUufTszPM1voIcwVhd0DpYZ1HwV05U6p3IS2DE=
|
||||
- ring: 1
|
||||
enabled: true
|
||||
keys:
|
||||
privatekey: APXGKqOxx1gOr587FSN3O3gRGpkGgSjt6zGlTu49UlU=
|
||||
publickey: av8ni/9ZUyozabzqTjIy1sOnSJuQ9p63Tu9ECVmHB2I=
|
||||
@@ -43,7 +43,7 @@ func gatewaySet(zi cluster.ZoneIterator, gw string) error {
|
||||
zi.ForEachZone(func(z *cluster.Zone) bool {
|
||||
for _, m := range z.Machines {
|
||||
if m.Name == gw {
|
||||
z.SetGateway(m.ID, true)
|
||||
_ = z.SetGateway(m.ID, true)
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -79,8 +79,8 @@ func gatewayUnset(zi cluster.ZoneIterator, ngw string) error {
|
||||
zi.ForEachZone(func(z *cluster.Zone) bool {
|
||||
for _, m := range z.Machines {
|
||||
if m.Name == ngw && m.IsGateway() {
|
||||
z.SetGateway(m.ID, false)
|
||||
m.RemoveWireguardConfig(0)
|
||||
_ = z.SetGateway(m.ID, false)
|
||||
_ = m.RemoveWireguardConfig(0)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/netip"
|
||||
"os"
|
||||
|
||||
"darvaza.org/core"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"git.jpi.io/amery/jpictl/pkg/cluster"
|
||||
"git.jpi.io/amery/jpictl/pkg/rings"
|
||||
"git.jpi.io/amery/jpictl/pkg/tools"
|
||||
)
|
||||
|
||||
type inventory struct {
|
||||
r []*cluster.Region
|
||||
z [][]*cluster.Zone
|
||||
}
|
||||
|
||||
func (g *inventory) renderRingZero(out *tools.LazyBuffer) error {
|
||||
ring0 := netip.PrefixFrom(rings.UnsafeRingZeroAddress(0, 0, 0), rings.RingZeroBits)
|
||||
from, to, _ := rings.PrefixToRange(ring0)
|
||||
|
||||
_ = out.Printf("; wg%v\n", 0)
|
||||
_ = out.Printf("%s\t%s-%s\n", ring0, from, to)
|
||||
|
||||
if err := g.renderRingZeroRegions(out); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return g.renderRingZeroZones(out)
|
||||
}
|
||||
|
||||
func (g *inventory) renderRingZeroRegions(out *tools.LazyBuffer) error {
|
||||
for _, r := range g.r {
|
||||
if err := g.renderRingZeroRegion(out, r); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*inventory) renderRingZeroRegion(out *tools.LazyBuffer, r *cluster.Region) error {
|
||||
addr := rings.UnsafeRingZeroAddress(r.ID, 0, 0)
|
||||
ring0r := netip.PrefixFrom(addr, rings.RingZeroBits+4)
|
||||
from, to, _ := rings.PrefixToRange(ring0r)
|
||||
|
||||
_ = out.Printf("%s\t%s-%s\t# %s\n", ring0r, from, to, r.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *inventory) renderRingZeroZones(out *tools.LazyBuffer) error {
|
||||
for i, r := range g.r {
|
||||
for _, z := range g.z[i] {
|
||||
if err := g.renderRingZeroZone(out, r, z); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (*inventory) renderRingZeroZone(out *tools.LazyBuffer, r *cluster.Region, z *cluster.Zone) error {
|
||||
addr := rings.UnsafeRingZeroAddress(r.ID, z.ID, 0)
|
||||
ring0rz := netip.PrefixFrom(addr, rings.RingZeroBits+4+4)
|
||||
from, to, _ := rings.PrefixToRange(ring0rz)
|
||||
|
||||
_ = out.Printf("; wg%v: %s (%s)\n", 0, z.Name, r.Name)
|
||||
_ = out.Printf("%s\t%s-%s\t%s\n", ring0rz, from, to, z.Name)
|
||||
|
||||
z.ForEachMachine(func(m *cluster.Machine) bool {
|
||||
if m.IsGateway() {
|
||||
addr, _ := m.RingZeroAddress()
|
||||
cidr := netip.PrefixFrom(addr, 32)
|
||||
_ = out.Printf("%s\t\t%s-%v\n", cidr, m.Name, 0)
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *inventory) renderRingOne(out *tools.LazyBuffer) error {
|
||||
for i, r := range g.r {
|
||||
for _, z := range g.z[i] {
|
||||
if err := g.renderRingOneZone(out, r, z); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*inventory) renderRingOneZone(out *tools.LazyBuffer, r *cluster.Region, z *cluster.Zone) error {
|
||||
ring1, err := rings.RingOnePrefix(r.ID, z.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
from, to, _ := rings.PrefixToRange(ring1)
|
||||
|
||||
_ = out.Printf("; wg%v: %s (%s)\n", 1, z.Name, r.Name)
|
||||
_ = out.Printf("%s\t%s-%s\t%s\n", ring1, from, to, z.Name)
|
||||
|
||||
z.ForEachMachine(func(m *cluster.Machine) bool {
|
||||
addr := m.RingOneAddress()
|
||||
cidr := netip.PrefixFrom(addr, 32)
|
||||
_ = out.Printf("%s\t\t%s-%v\n", cidr, m.Name, 1)
|
||||
return false
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *inventory) Marshal() ([]byte, error) {
|
||||
var buf tools.LazyBuffer
|
||||
|
||||
if err := g.renderRingZero(&buf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := g.renderRingOne(&buf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func (g *inventory) WriteTo(out io.Writer) (int64, error) {
|
||||
b, err := g.Marshal()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(b)
|
||||
return buf.WriteTo(out)
|
||||
}
|
||||
|
||||
func genInventory(m *cluster.Cluster) (*inventory, error) {
|
||||
g := new(inventory)
|
||||
|
||||
g.populateRegions(m)
|
||||
g.populateZones()
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func (g *inventory) populateRegions(m *cluster.Cluster) {
|
||||
m.ForEachRegion(func(r *cluster.Region) bool {
|
||||
if r.IsPrimary() {
|
||||
g.r = append(g.r, r)
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
core.SliceSortFn(g.r, func(a, b *cluster.Region) bool {
|
||||
return a.ID < b.ID
|
||||
})
|
||||
}
|
||||
|
||||
func (g *inventory) populateZones() {
|
||||
g.z = make([][]*cluster.Zone, len(g.r))
|
||||
for i, r := range g.r {
|
||||
r.ForEachZone(func(z *cluster.Zone) bool {
|
||||
g.z[i] = append(g.z[i], z)
|
||||
return false
|
||||
})
|
||||
|
||||
core.SliceSortFn(g.z[i], func(a, b *cluster.Zone) bool {
|
||||
return a.ID < b.ID
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Command
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "list shows the IP/CIDR inventory",
|
||||
PreRun: setVerbosity,
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
m, err := cfg.LoadZones(false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out, err := genInventory(m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = out.WriteTo(os.Stdout)
|
||||
return err
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(listCmd)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "../../../bitbucket.org/jpi/m.jpi.cloud"
|
||||
},
|
||||
{
|
||||
"path": "../../../darvaza.org/core"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
[global]
|
||||
fsid = 28180b9b-6d5d-4be0-bb5b-e4b04bf03804
|
||||
mon_initial_members = ssd-lon-7, ssd-ams-4, htz-fsn-1, ssd-nyc-3
|
||||
mon_host = 10.2.16.7, 10.1.32.4, 10.1.48.1, 10.3.64.3
|
||||
cluster_network = 10.0.0.0/8
|
||||
|
||||
; don't rewrite labels on startup
|
||||
osd_class_update_on_start = false
|
||||
@@ -0,0 +1,2 @@
|
||||
de
|
||||
nl
|
||||
@@ -0,0 +1,2 @@
|
||||
eu
|
||||
uk
|
||||
@@ -0,0 +1,2 @@
|
||||
europe
|
||||
us
|
||||
@@ -0,0 +1,22 @@
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
|
||||
10.2.16.3 ssd-lon-3
|
||||
10.2.16.7 ssd-lon-7 ssd-lon-ceph ssd-lon-k3s
|
||||
10.1.32.3 ssd-ams-3
|
||||
10.1.32.4 ssd-ams-4 ssd-ams-ceph ssd-ams-k3s
|
||||
10.1.32.5 ssd-ams-5
|
||||
10.1.48.1 htz-fsn-1 htz-fsn-ceph htz-fsn-k3s ceph k3s
|
||||
10.3.64.3 ssd-nyc-3 ssd-nyc-ceph ssd-nyc-k3s
|
||||
|
||||
10.0.33.3 ssd-lon-3-0
|
||||
10.0.18.3 ssd-ams-3-0
|
||||
10.0.19.1 htz-fsn-1-0
|
||||
10.0.52.3 ssd-nyc-3-0
|
||||
@@ -0,0 +1,23 @@
|
||||
[Interface]
|
||||
# Name: htz-fsn-1-0
|
||||
Address = 10.0.19.1
|
||||
PrivateKey = AMz/pCgOMVh1/2rT9uCFMox+LQgH5FrE4xUeqSs0x0M=
|
||||
ListenPort = 51800
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-lon-3-0
|
||||
PublicKey = aDXNwapVjufcuQKfBN+waJObe1TaeeaSNl1suA0u+00=
|
||||
Endpoint = ssd-lon-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.2.16.0/20, 10.0.33.3/32
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-3-0
|
||||
PublicKey = y/Gkid2Mjxo1WO9Zi7mh+DETNYKT/AAc3K3bvr9xp3c=
|
||||
Endpoint = ssd-ams-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.1.32.0/20, 10.0.18.3/32
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-nyc-3-0
|
||||
PublicKey = 1UFgleUufTszPM1voIcwVhd0DpYZ1HwV05U6p3IS2DE=
|
||||
Endpoint = ssd-nyc-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.3.64.0/20, 10.0.52.3/32
|
||||
@@ -0,0 +1 @@
|
||||
AMz/pCgOMVh1/2rT9uCFMox+LQgH5FrE4xUeqSs0x0M=
|
||||
@@ -0,0 +1 @@
|
||||
K9LYog8vtRFN4nW6dJWMQ9trmRrYuLpbu/Ze5kIiBGw=
|
||||
@@ -0,0 +1,5 @@
|
||||
[Interface]
|
||||
# Name: htz-fsn-1-1
|
||||
Address = 10.1.48.1
|
||||
PrivateKey = 2JpA1G0Dp+sEuDhKnzToz0h76o2iLP+S7Qb9itlgXVA=
|
||||
ListenPort = 51810
|
||||
@@ -0,0 +1 @@
|
||||
2JpA1G0Dp+sEuDhKnzToz0h76o2iLP+S7Qb9itlgXVA=
|
||||
@@ -0,0 +1 @@
|
||||
qWmYfgeRAQ563gWLdeYs65XjGJTSE+W8WTbpLZ0e1CQ=
|
||||
@@ -0,0 +1 @@
|
||||
de
|
||||
@@ -0,0 +1 @@
|
||||
nl
|
||||
@@ -0,0 +1,22 @@
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
|
||||
10.2.16.3 ssd-lon-3
|
||||
10.2.16.7 ssd-lon-7 ssd-lon-ceph ssd-lon-k3s
|
||||
10.1.32.3 ssd-ams-3
|
||||
10.1.32.4 ssd-ams-4 ssd-ams-ceph ssd-ams-k3s ceph k3s
|
||||
10.1.32.5 ssd-ams-5
|
||||
10.1.48.1 htz-fsn-1 htz-fsn-ceph htz-fsn-k3s
|
||||
10.3.64.3 ssd-nyc-3 ssd-nyc-ceph ssd-nyc-k3s
|
||||
|
||||
10.0.33.3 ssd-lon-3-0
|
||||
10.0.18.3 ssd-ams-3-0
|
||||
10.0.19.1 htz-fsn-1-0
|
||||
10.0.52.3 ssd-nyc-3-0
|
||||
@@ -0,0 +1,23 @@
|
||||
[Interface]
|
||||
# Name: ssd-ams-3-0
|
||||
Address = 10.0.18.3
|
||||
PrivateKey = oHVQY976pFH1lAhCrz9c40vR/e5PIXw7ZXv6pU6A5Ho=
|
||||
ListenPort = 51800
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-lon-3-0
|
||||
PublicKey = aDXNwapVjufcuQKfBN+waJObe1TaeeaSNl1suA0u+00=
|
||||
Endpoint = ssd-lon-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.2.16.0/20, 10.0.33.3/32
|
||||
|
||||
[Peer]
|
||||
# Name: htz-fsn-1-0
|
||||
PublicKey = K9LYog8vtRFN4nW6dJWMQ9trmRrYuLpbu/Ze5kIiBGw=
|
||||
Endpoint = htz-fsn-1.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.1.48.0/20, 10.0.19.1/32
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-nyc-3-0
|
||||
PublicKey = 1UFgleUufTszPM1voIcwVhd0DpYZ1HwV05U6p3IS2DE=
|
||||
Endpoint = ssd-nyc-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.3.64.0/20, 10.0.52.3/32
|
||||
@@ -0,0 +1 @@
|
||||
oHVQY976pFH1lAhCrz9c40vR/e5PIXw7ZXv6pU6A5Ho=
|
||||
@@ -0,0 +1 @@
|
||||
y/Gkid2Mjxo1WO9Zi7mh+DETNYKT/AAc3K3bvr9xp3c=
|
||||
@@ -0,0 +1,17 @@
|
||||
[Interface]
|
||||
# Name: ssd-ams-3-1
|
||||
Address = 10.1.32.3
|
||||
PrivateKey = 6I/ZMxaWUTbNc+SIGkNKxgovONqv6EAvg7NeeTRrR1c=
|
||||
ListenPort = 51810
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-4-1
|
||||
PublicKey = QpJupYlnJc7wc3+gAlEmbFMonsqpVnYRy7f/gnPqqBw=
|
||||
Endpoint = ssd-ams-4.m.jpi.cloud:51810
|
||||
AllowedIPs = 10.1.32.4/32
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-5-1
|
||||
PublicKey = HDLVEwLv0uugyZ9C1C9ZWuiaWQ1qIqqe/DAUxYI0whM=
|
||||
Endpoint = ssd-ams-5.m.jpi.cloud:51810
|
||||
AllowedIPs = 10.1.32.5/32
|
||||
@@ -0,0 +1 @@
|
||||
6I/ZMxaWUTbNc+SIGkNKxgovONqv6EAvg7NeeTRrR1c=
|
||||
@@ -0,0 +1 @@
|
||||
9i0XI358OOYYoxoxV5lX8siqE8uiEwCsuWLo6LoFu0Y=
|
||||
@@ -0,0 +1,22 @@
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
|
||||
10.2.16.3 ssd-lon-3
|
||||
10.2.16.7 ssd-lon-7 ssd-lon-ceph ssd-lon-k3s
|
||||
10.1.32.3 ssd-ams-3
|
||||
10.1.32.4 ssd-ams-4 ssd-ams-ceph ssd-ams-k3s ceph k3s
|
||||
10.1.32.5 ssd-ams-5
|
||||
10.1.48.1 htz-fsn-1 htz-fsn-ceph htz-fsn-k3s
|
||||
10.3.64.3 ssd-nyc-3 ssd-nyc-ceph ssd-nyc-k3s
|
||||
|
||||
10.0.33.3 ssd-lon-3-0
|
||||
10.0.18.3 ssd-ams-3-0
|
||||
10.0.19.1 htz-fsn-1-0
|
||||
10.0.52.3 ssd-nyc-3-0
|
||||
@@ -0,0 +1,17 @@
|
||||
[Interface]
|
||||
# Name: ssd-ams-4-1
|
||||
Address = 10.1.32.4
|
||||
PrivateKey = SPBd5Ka29ZecKYy7BW85rW7FO9dwKwoUHlSibybPG1s=
|
||||
ListenPort = 51810
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-3-1
|
||||
PublicKey = 9i0XI358OOYYoxoxV5lX8siqE8uiEwCsuWLo6LoFu0Y=
|
||||
Endpoint = ssd-ams-3.m.jpi.cloud:51810
|
||||
AllowedIPs = 10.1.32.3/32, 10.2.16.0/20, 10.1.48.0/20, 10.3.64.0/20, 10.0.33.3/32, 10.0.18.3/32, 10.0.19.1/32, 10.0.52.3/32
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-5-1
|
||||
PublicKey = HDLVEwLv0uugyZ9C1C9ZWuiaWQ1qIqqe/DAUxYI0whM=
|
||||
Endpoint = ssd-ams-5.m.jpi.cloud:51810
|
||||
AllowedIPs = 10.1.32.5/32
|
||||
@@ -0,0 +1 @@
|
||||
SPBd5Ka29ZecKYy7BW85rW7FO9dwKwoUHlSibybPG1s=
|
||||
@@ -0,0 +1 @@
|
||||
QpJupYlnJc7wc3+gAlEmbFMonsqpVnYRy7f/gnPqqBw=
|
||||
@@ -0,0 +1,22 @@
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
|
||||
10.2.16.3 ssd-lon-3
|
||||
10.2.16.7 ssd-lon-7 ssd-lon-ceph ssd-lon-k3s
|
||||
10.1.32.3 ssd-ams-3
|
||||
10.1.32.4 ssd-ams-4 ssd-ams-ceph ssd-ams-k3s ceph k3s
|
||||
10.1.32.5 ssd-ams-5
|
||||
10.1.48.1 htz-fsn-1 htz-fsn-ceph htz-fsn-k3s
|
||||
10.3.64.3 ssd-nyc-3 ssd-nyc-ceph ssd-nyc-k3s
|
||||
|
||||
10.0.33.3 ssd-lon-3-0
|
||||
10.0.18.3 ssd-ams-3-0
|
||||
10.0.19.1 htz-fsn-1-0
|
||||
10.0.52.3 ssd-nyc-3-0
|
||||
@@ -0,0 +1 @@
|
||||
none
|
||||
@@ -0,0 +1,17 @@
|
||||
[Interface]
|
||||
# Name: ssd-ams-5-1
|
||||
Address = 10.1.32.5
|
||||
PrivateKey = mJaFvu9TBwE2i0rjhfhvpB3xZmp++3BVwa7QAvWXImY=
|
||||
ListenPort = 51810
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-3-1
|
||||
PublicKey = 9i0XI358OOYYoxoxV5lX8siqE8uiEwCsuWLo6LoFu0Y=
|
||||
Endpoint = ssd-ams-3.m.jpi.cloud:51810
|
||||
AllowedIPs = 10.1.32.3/32, 10.2.16.0/20, 10.1.48.0/20, 10.3.64.0/20, 10.0.33.3/32, 10.0.18.3/32, 10.0.19.1/32, 10.0.52.3/32
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-4-1
|
||||
PublicKey = QpJupYlnJc7wc3+gAlEmbFMonsqpVnYRy7f/gnPqqBw=
|
||||
Endpoint = ssd-ams-4.m.jpi.cloud:51810
|
||||
AllowedIPs = 10.1.32.4/32
|
||||
@@ -0,0 +1 @@
|
||||
mJaFvu9TBwE2i0rjhfhvpB3xZmp++3BVwa7QAvWXImY=
|
||||
@@ -0,0 +1 @@
|
||||
HDLVEwLv0uugyZ9C1C9ZWuiaWQ1qIqqe/DAUxYI0whM=
|
||||
@@ -0,0 +1 @@
|
||||
uk
|
||||
@@ -0,0 +1,22 @@
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
|
||||
10.2.16.3 ssd-lon-3
|
||||
10.2.16.7 ssd-lon-7 ssd-lon-ceph ssd-lon-k3s ceph k3s
|
||||
10.1.32.3 ssd-ams-3
|
||||
10.1.32.4 ssd-ams-4 ssd-ams-ceph ssd-ams-k3s
|
||||
10.1.32.5 ssd-ams-5
|
||||
10.1.48.1 htz-fsn-1 htz-fsn-ceph htz-fsn-k3s
|
||||
10.3.64.3 ssd-nyc-3 ssd-nyc-ceph ssd-nyc-k3s
|
||||
|
||||
10.0.33.3 ssd-lon-3-0
|
||||
10.0.18.3 ssd-ams-3-0
|
||||
10.0.19.1 htz-fsn-1-0
|
||||
10.0.52.3 ssd-nyc-3-0
|
||||
@@ -0,0 +1,23 @@
|
||||
[Interface]
|
||||
# Name: ssd-lon-3-0
|
||||
Address = 10.0.33.3
|
||||
PrivateKey = WJY1yrd14c0gY4qqq1O8BPck46TVYebXrT+OoMbEqG8=
|
||||
ListenPort = 51800
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-3-0
|
||||
PublicKey = y/Gkid2Mjxo1WO9Zi7mh+DETNYKT/AAc3K3bvr9xp3c=
|
||||
Endpoint = ssd-ams-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.1.32.0/20, 10.0.18.3/32
|
||||
|
||||
[Peer]
|
||||
# Name: htz-fsn-1-0
|
||||
PublicKey = K9LYog8vtRFN4nW6dJWMQ9trmRrYuLpbu/Ze5kIiBGw=
|
||||
Endpoint = htz-fsn-1.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.1.48.0/20, 10.0.19.1/32
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-nyc-3-0
|
||||
PublicKey = 1UFgleUufTszPM1voIcwVhd0DpYZ1HwV05U6p3IS2DE=
|
||||
Endpoint = ssd-nyc-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.3.64.0/20, 10.0.52.3/32
|
||||
@@ -0,0 +1 @@
|
||||
WJY1yrd14c0gY4qqq1O8BPck46TVYebXrT+OoMbEqG8=
|
||||
@@ -0,0 +1 @@
|
||||
aDXNwapVjufcuQKfBN+waJObe1TaeeaSNl1suA0u+00=
|
||||
@@ -0,0 +1,11 @@
|
||||
[Interface]
|
||||
# Name: ssd-lon-3-1
|
||||
Address = 10.2.16.3
|
||||
PrivateKey = 2CDO+x8HVKfw1/iqC2WkwIEQyWZsC9XPW1otqxarR0o=
|
||||
ListenPort = 51810
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-lon-7-1
|
||||
PublicKey = XGVXDmxQajHpsgpzgrp+r/ZWxZUaodTpvGBJuLlZ0n4=
|
||||
Endpoint = ssd-lon-7.m.jpi.cloud:51810
|
||||
AllowedIPs = 10.2.16.7/32
|
||||
@@ -0,0 +1 @@
|
||||
2CDO+x8HVKfw1/iqC2WkwIEQyWZsC9XPW1otqxarR0o=
|
||||
@@ -0,0 +1 @@
|
||||
untmMfW2W4OiMgG/6nAysoivXtDh7cZ9/rxhgJ4OlC4=
|
||||
@@ -0,0 +1,22 @@
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
|
||||
10.2.16.3 ssd-lon-3
|
||||
10.2.16.7 ssd-lon-7 ssd-lon-ceph ssd-lon-k3s ceph k3s
|
||||
10.1.32.3 ssd-ams-3
|
||||
10.1.32.4 ssd-ams-4 ssd-ams-ceph ssd-ams-k3s
|
||||
10.1.32.5 ssd-ams-5
|
||||
10.1.48.1 htz-fsn-1 htz-fsn-ceph htz-fsn-k3s
|
||||
10.3.64.3 ssd-nyc-3 ssd-nyc-ceph ssd-nyc-k3s
|
||||
|
||||
10.0.33.3 ssd-lon-3-0
|
||||
10.0.18.3 ssd-ams-3-0
|
||||
10.0.19.1 htz-fsn-1-0
|
||||
10.0.52.3 ssd-nyc-3-0
|
||||
@@ -0,0 +1,11 @@
|
||||
[Interface]
|
||||
# Name: ssd-lon-7-1
|
||||
Address = 10.2.16.7
|
||||
PrivateKey = iN4Rc3J36APlkIP/ksSpHIwAuxC/ehYLwGQ5va1AhG8=
|
||||
ListenPort = 51810
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-lon-3-1
|
||||
PublicKey = untmMfW2W4OiMgG/6nAysoivXtDh7cZ9/rxhgJ4OlC4=
|
||||
Endpoint = ssd-lon-3.m.jpi.cloud:51810
|
||||
AllowedIPs = 10.2.16.3/32, 10.1.32.0/20, 10.1.48.0/20, 10.3.64.0/20, 10.0.33.3/32, 10.0.18.3/32, 10.0.19.1/32, 10.0.52.3/32
|
||||
@@ -0,0 +1 @@
|
||||
iN4Rc3J36APlkIP/ksSpHIwAuxC/ehYLwGQ5va1AhG8=
|
||||
@@ -0,0 +1 @@
|
||||
XGVXDmxQajHpsgpzgrp+r/ZWxZUaodTpvGBJuLlZ0n4=
|
||||
@@ -0,0 +1 @@
|
||||
us
|
||||
@@ -0,0 +1,22 @@
|
||||
127.0.0.1 localhost
|
||||
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
ff00::0 ip6-mcastprefix
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
|
||||
10.2.16.3 ssd-lon-3
|
||||
10.2.16.7 ssd-lon-7 ssd-lon-ceph ssd-lon-k3s
|
||||
10.1.32.3 ssd-ams-3
|
||||
10.1.32.4 ssd-ams-4 ssd-ams-ceph ssd-ams-k3s
|
||||
10.1.32.5 ssd-ams-5
|
||||
10.1.48.1 htz-fsn-1 htz-fsn-ceph htz-fsn-k3s
|
||||
10.3.64.3 ssd-nyc-3 ssd-nyc-ceph ssd-nyc-k3s ceph k3s
|
||||
|
||||
10.0.33.3 ssd-lon-3-0
|
||||
10.0.18.3 ssd-ams-3-0
|
||||
10.0.19.1 htz-fsn-1-0
|
||||
10.0.52.3 ssd-nyc-3-0
|
||||
@@ -0,0 +1 @@
|
||||
none
|
||||
@@ -0,0 +1,23 @@
|
||||
[Interface]
|
||||
# Name: ssd-nyc-3-0
|
||||
Address = 10.0.52.3
|
||||
PrivateKey = YNDxj+QSO3p5pXw9h7lBx0cLM0kJDv3v7BYLfc8TR3I=
|
||||
ListenPort = 51800
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-lon-3-0
|
||||
PublicKey = aDXNwapVjufcuQKfBN+waJObe1TaeeaSNl1suA0u+00=
|
||||
Endpoint = ssd-lon-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.2.16.0/20, 10.0.33.3/32
|
||||
|
||||
[Peer]
|
||||
# Name: ssd-ams-3-0
|
||||
PublicKey = y/Gkid2Mjxo1WO9Zi7mh+DETNYKT/AAc3K3bvr9xp3c=
|
||||
Endpoint = ssd-ams-3.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.1.32.0/20, 10.0.18.3/32
|
||||
|
||||
[Peer]
|
||||
# Name: htz-fsn-1-0
|
||||
PublicKey = K9LYog8vtRFN4nW6dJWMQ9trmRrYuLpbu/Ze5kIiBGw=
|
||||
Endpoint = htz-fsn-1.m.jpi.cloud:51800
|
||||
AllowedIPs = 10.1.48.0/20, 10.0.19.1/32
|
||||
@@ -0,0 +1 @@
|
||||
YNDxj+QSO3p5pXw9h7lBx0cLM0kJDv3v7BYLfc8TR3I=
|
||||
@@ -0,0 +1 @@
|
||||
1UFgleUufTszPM1voIcwVhd0DpYZ1HwV05U6p3IS2DE=
|
||||
@@ -0,0 +1,5 @@
|
||||
[Interface]
|
||||
# Name: ssd-nyc-3-1
|
||||
Address = 10.3.64.3
|
||||
PrivateKey = APXGKqOxx1gOr587FSN3O3gRGpkGgSjt6zGlTu49UlU=
|
||||
ListenPort = 51810
|
||||
@@ -0,0 +1 @@
|
||||
APXGKqOxx1gOr587FSN3O3gRGpkGgSjt6zGlTu49UlU=
|
||||
@@ -0,0 +1 @@
|
||||
av8ni/9ZUyozabzqTjIy1sOnSJuQ9p63Tu9ECVmHB2I=
|
||||
@@ -73,10 +73,7 @@ func newCephScanTODO(cfg *ceph.Config) *cephScanTODO {
|
||||
|
||||
func (m *Cluster) scanCephMonitors(opts *ScanOptions) error {
|
||||
cfg, err := m.GetCephConfig()
|
||||
switch {
|
||||
case os.IsNotExist(err):
|
||||
err = nil
|
||||
case err != nil:
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package cluster
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/netip"
|
||||
"strconv"
|
||||
|
||||
@@ -231,26 +232,36 @@ func (r *Ring) setRingOneGatewayAllowedIPs(rp *RingPeer) {
|
||||
// peer
|
||||
rp.AllowCIDR(rp.Address, 32)
|
||||
|
||||
log.Println(rp.Node.Name, "0:", rp.Address, regionID, zoneID)
|
||||
|
||||
// ring1 gateways connect to all other ring1 networks
|
||||
r.ForEachZone(func(z *Zone) bool {
|
||||
log.Println(rp.Node.Name, "1:", z.Name, z.RegionID(), z.ID)
|
||||
|
||||
if !z.Is(regionID, zoneID) {
|
||||
subnet := z.RingOnePrefix()
|
||||
rp.AllowSubnet(subnet)
|
||||
log.Println(rp.Node.Name, "1.1:", rp.PeerConfig.AllowedIPs)
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
// ring1 gateways also connect to all ring0 addresses
|
||||
r.ForEachZone(func(z *Zone) bool {
|
||||
log.Println(rp.Node.Name, "2:", z.Name, z.RegionID(), z.ID)
|
||||
z.ForEachMachine(func(p *Machine) bool {
|
||||
log.Println(rp.Node.Name, "2.1:", p.Name, p.IsGateway())
|
||||
if p.IsGateway() {
|
||||
addr, _ := p.RingZeroAddress()
|
||||
rp.AllowCIDR(addr, 32)
|
||||
log.Println(rp.Node.Name, "2.2:", rp.PeerConfig.AllowedIPs)
|
||||
}
|
||||
return false
|
||||
})
|
||||
return false
|
||||
})
|
||||
|
||||
log.Println(rp.Node.Name, "3:", rp.PeerConfig.AllowedIPs)
|
||||
}
|
||||
|
||||
func (*Ring) setRingOneNodeAllowedIPs(rp *RingPeer) {
|
||||
|
||||
+19
-10
@@ -14,7 +14,7 @@ func RingZeroPrefix(region RegionID, zone ZoneID) (cidr netip.Prefix, err error)
|
||||
case !zone.Valid():
|
||||
err = ErrOutOfRange(zone, "zone")
|
||||
default:
|
||||
addr := unsafeRingZeroAddress(region, zone, 0)
|
||||
addr := UnsafeRingZeroAddress(region, zone, 0)
|
||||
cidr = netip.PrefixFrom(addr, RingZeroBits)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func RingZeroAddress(region RegionID, zone ZoneID, node NodeID) (addr netip.Addr
|
||||
case !node.ValidZero():
|
||||
err = ErrOutOfRange(node, "node")
|
||||
default:
|
||||
addr = unsafeRingZeroAddress(region, zone, node)
|
||||
addr = UnsafeRingZeroAddress(region, zone, node)
|
||||
}
|
||||
|
||||
return addr, err
|
||||
@@ -52,7 +52,7 @@ func RingOnePrefix(region RegionID, zone ZoneID) (cidr netip.Prefix, err error)
|
||||
case !zone.Valid():
|
||||
err = ErrOutOfRange(zone, "zone")
|
||||
default:
|
||||
addr := unsafeRingOneAddress(region, zone, 0)
|
||||
addr := UnsafeRingOneAddress(region, zone, 0)
|
||||
cidr = netip.PrefixFrom(addr, RingOneBits)
|
||||
}
|
||||
return cidr, err
|
||||
@@ -71,7 +71,7 @@ func RingOneAddress(region RegionID, zone ZoneID, node NodeID) (addr netip.Addr,
|
||||
case !node.Valid():
|
||||
err = ErrOutOfRange(node, "node")
|
||||
default:
|
||||
addr = unsafeRingOneAddress(region, zone, node)
|
||||
addr = UnsafeRingOneAddress(region, zone, node)
|
||||
}
|
||||
return addr, err
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func RingTwoPrefix(region RegionID) (cidr netip.Prefix, err error) {
|
||||
case !region.Valid():
|
||||
err = ErrOutOfRange(region, "region")
|
||||
default:
|
||||
addr := unsafeRingTwoAddress(region, 0)
|
||||
addr := UnsafeRingTwoAddress(region, 0)
|
||||
cidr = netip.PrefixFrom(addr, RingTwoBits)
|
||||
}
|
||||
return cidr, err
|
||||
@@ -101,20 +101,25 @@ func RingThreePrefix(region RegionID) (subnet netip.Prefix, err error) {
|
||||
case !region.Valid():
|
||||
err = ErrOutOfRange(region, "region")
|
||||
default:
|
||||
addr := unsafeRingThreeAddress(region, 0)
|
||||
addr := UnsafeRingThreeAddress(region, 0)
|
||||
subnet = netip.PrefixFrom(addr, RingThreeBits)
|
||||
}
|
||||
return subnet, err
|
||||
}
|
||||
|
||||
func unsafeRingZeroAddress(region RegionID, zone ZoneID, node NodeID) netip.Addr {
|
||||
// UnsafeRingZeroAddress is equivalent ot RingZeroAddress but without validating
|
||||
// the input.
|
||||
func UnsafeRingZeroAddress(region RegionID, zone ZoneID, node NodeID) netip.Addr {
|
||||
r := uint(region)
|
||||
z := uint(zone)
|
||||
n := uint(node)
|
||||
|
||||
return AddrFrom4(10, 0, r<<4+z, n)
|
||||
}
|
||||
func unsafeRingOneAddress(region RegionID, zone ZoneID, node NodeID) netip.Addr {
|
||||
|
||||
// UnsafeRingOneAddress is equivalent ot RingOneAddress but without validating
|
||||
// the input.
|
||||
func UnsafeRingOneAddress(region RegionID, zone ZoneID, node NodeID) netip.Addr {
|
||||
r := uint(region)
|
||||
z := uint(zone)
|
||||
n := uint(node)
|
||||
@@ -125,7 +130,9 @@ func unsafeRingOneAddress(region RegionID, zone ZoneID, node NodeID) netip.Addr
|
||||
return AddrFrom4(10, r, z<<4+n1, n0)
|
||||
}
|
||||
|
||||
func unsafeRingTwoAddress(region RegionID, n uint) netip.Addr {
|
||||
// UnsafeRingTwoAddress is equivalent ot RingTwoAddress but without validating
|
||||
// the input.
|
||||
func UnsafeRingTwoAddress(region RegionID, n uint) netip.Addr {
|
||||
r := uint(region)
|
||||
|
||||
n1 := n >> 8
|
||||
@@ -134,7 +141,9 @@ func unsafeRingTwoAddress(region RegionID, n uint) netip.Addr {
|
||||
return AddrFrom4(10, r, n1, n0)
|
||||
}
|
||||
|
||||
func unsafeRingThreeAddress(region RegionID, n uint) netip.Addr {
|
||||
// UnsafeRingThreeAddress is equivalent ot RingThreeAddress but without validating
|
||||
// the input.
|
||||
func UnsafeRingThreeAddress(region RegionID, n uint) netip.Addr {
|
||||
r := uint(region)
|
||||
|
||||
n2 := n >> 16
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// LazyBuffer is a [bytes.Buffer] that minimizes counting and error checks.
|
||||
type LazyBuffer bytes.Buffer
|
||||
|
||||
// Sys returns the underlying [bytes.Buffer].
|
||||
func (buf *LazyBuffer) Sys() *bytes.Buffer {
|
||||
if buf == nil {
|
||||
return nil
|
||||
}
|
||||
return (*bytes.Buffer)(buf)
|
||||
}
|
||||
|
||||
// Len tells the size in bytes of the currently stored data.
|
||||
func (buf *LazyBuffer) Len() int { return buf.Sys().Len() }
|
||||
|
||||
// String returns the stored data as string.
|
||||
func (buf *LazyBuffer) String() string { return buf.Sys().String() }
|
||||
|
||||
// Bytes returns the stored data as a bytes slice.
|
||||
func (buf *LazyBuffer) Bytes() []byte { return buf.Sys().Bytes() }
|
||||
|
||||
// Write implements the standard io.Writer interface.
|
||||
func (buf *LazyBuffer) Write(b []byte) (int, error) { return buf.Sys().Write(b) }
|
||||
|
||||
// WriteTo implements the standard WriteTo() interface.
|
||||
func (buf *LazyBuffer) WriteTo(out io.Writer) (int64, error) { return buf.Sys().WriteTo(out) }
|
||||
|
||||
// Print appends the [fmt.Print] equivalent to the buffer.
|
||||
func (buf *LazyBuffer) Print(a ...any) error {
|
||||
_, err := fmt.Fprint(buf.Sys(), a...)
|
||||
return err
|
||||
}
|
||||
|
||||
// Println appends the [fmt.Println] equivalent to the buffer.
|
||||
func (buf *LazyBuffer) Println(a ...any) error {
|
||||
_, err := fmt.Fprintln(buf.Sys(), a...)
|
||||
return err
|
||||
}
|
||||
|
||||
// Printf appends the [fmt.Printf] equivalent to the buffer.
|
||||
func (buf *LazyBuffer) Printf(format string, a ...any) error {
|
||||
_, err := fmt.Fprintf(buf.Sys(), format, a...)
|
||||
return err
|
||||
}
|
||||
|
||||
// WriteRunes appends the given runes as UTF-8 characters to the buffer.
|
||||
func (buf *LazyBuffer) WriteRunes(runes ...rune) {
|
||||
for _, r := range runes {
|
||||
_, _ = buf.Sys().WriteRune(r)
|
||||
}
|
||||
}
|
||||
|
||||
// WriteBytes writes the given byte arrays to the buffer.
|
||||
func (buf *LazyBuffer) WriteBytes(s ...[]byte) {
|
||||
for _, b := range s {
|
||||
_, _ = buf.Sys().Write(b)
|
||||
}
|
||||
}
|
||||
|
||||
// WriteStrings writes the given strings as UTF-8 to the buffer.
|
||||
func (buf *LazyBuffer) WriteStrings(strings ...string) {
|
||||
for _, s := range strings {
|
||||
_, _ = buf.Sys().WriteString(s)
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -1,3 +1,11 @@
|
||||
//go:build tools
|
||||
// Package tools contains helpers
|
||||
package tools
|
||||
|
||||
package build
|
||||
import "io"
|
||||
|
||||
// LazyClose closes an [io.Closer] and discards the error
|
||||
func LazyClose(p io.Closer) {
|
||||
if p != nil {
|
||||
_ = p.Close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
"darvaza.org/core"
|
||||
)
|
||||
|
||||
type sectionHandler func(*Config, *basic.Section) error
|
||||
|
||||
var sectionMap = map[string]func(*Config, *basic.Section) error{
|
||||
"Interface": loadInterfaceConfSection,
|
||||
"Peer": loadPeerConfSection,
|
||||
|
||||
Reference in New Issue
Block a user