mirror of
https://github.com/cunnie/sslip.io.git
synced 2025-10-07 00:23:44 +08:00
Laying the groundwork for passed-in configuration
The massive 80+ line `Customizations` variable is a hard-coded monstrosity, and I've fallen out of love with it. I'd like the customizations to be passed in from the caller, in this case, `main.go`. To that end, I've created a `default.json`, which should contain all the customizations with the exception of the key-value functionality, which I don't have a good way to deal with just yet.
This commit is contained in:
85
src/sslip.io-dns-server/default.json
Normal file
85
src/sslip.io-dns-server/default.json
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"sslip.io.": {
|
||||||
|
"A": [
|
||||||
|
"78.46.204.247"
|
||||||
|
],
|
||||||
|
"AAAA": [
|
||||||
|
"2a01:4f8:c17:b8f::2"
|
||||||
|
],
|
||||||
|
"MX": [
|
||||||
|
{
|
||||||
|
"Pref": 10,
|
||||||
|
"MX": "mail.protonmail.ch."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Pref": 10,
|
||||||
|
"MX": "mailsec.protonmail.ch."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"TXT": [
|
||||||
|
"TXTSslipIoSPF"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"k-v.io.": {
|
||||||
|
"A": [
|
||||||
|
"104.155.144.4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_acme-challenge.k-v.io.": {
|
||||||
|
"TXT": []
|
||||||
|
},
|
||||||
|
"ns.sslip.io.": {
|
||||||
|
"A": [
|
||||||
|
"52.0.56.137",
|
||||||
|
"52.187.42.158",
|
||||||
|
"104.155.144.4"
|
||||||
|
],
|
||||||
|
"AAAA": [
|
||||||
|
"2600:1f18:aaf:6900::a"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ns-aws.sslip.io.": {
|
||||||
|
"A": [
|
||||||
|
"52.0.56.137"
|
||||||
|
],
|
||||||
|
"AAAA": [
|
||||||
|
"2600:1f18:aaf:6900::a"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ns-azure.sslip.io.": {
|
||||||
|
"A": [
|
||||||
|
"52.187.42.158"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ns-gce.sslip.io.": {
|
||||||
|
"A": [
|
||||||
|
"104.155.144.4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"protonmail._domainkey.sslip.io.": {
|
||||||
|
"CNAME": "protonmail.domainkey.dw4gykv5i2brtkjglrf34wf6kbxpa5hgtmg2xqopinhgxn5axo73a.domains.proton.ch."
|
||||||
|
},
|
||||||
|
"protonmail2._domainkey.sslip.io.": {
|
||||||
|
"CNAME": "protonmail2.domainkey.dw4gykv5i2brtkjglrf34wf6kbxpa5hgtmg2xqopinhgxn5axo73a.domains.proton.ch."
|
||||||
|
},
|
||||||
|
"protonmail3._domainkey.sslip.io.": {
|
||||||
|
"CNAME": "protonmail3.domainkey.dw4gykv5i2brtkjglrf34wf6kbxpa5hgtmg2xqopinhgxn5axo73a.domains.proton.ch."
|
||||||
|
},
|
||||||
|
"ip.sslip.io.": {
|
||||||
|
"TXT": [
|
||||||
|
"TXTIp"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"version.status.sslip.io.": {
|
||||||
|
"TXT": [
|
||||||
|
"TXTVersion"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metrics.status.sslip.io.": {
|
||||||
|
"TXT": [
|
||||||
|
"TXTMetrics"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@@ -153,15 +153,7 @@ var (
|
|||||||
MX: mx2,
|
MX: mx2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TXT: func(_ *Xip, _ net.IP) ([]dnsmessage.TXTResource, error) {
|
TXT: TXTSslipIoSPF,
|
||||||
// Although multiple TXT records with multiple strings are allowed, we're sticking
|
|
||||||
// with a multiple TXT records with a single string apiece because that's what ProtonMail requires
|
|
||||||
// and that's what google.com does.
|
|
||||||
return []dnsmessage.TXTResource{
|
|
||||||
{TXT: []string{"protonmail-verification=ce0ca3f5010aa7a2cf8bcc693778338ffde73e26"}}, // ProtonMail verification; don't delete
|
|
||||||
{TXT: []string{"v=spf1 include:_spf.protonmail.ch mx ~all"}},
|
|
||||||
}, nil // Sender Policy Framework
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"k-v.io.": {
|
"k-v.io.": {
|
||||||
A: []dnsmessage.AResource{
|
A: []dnsmessage.AResource{
|
||||||
@@ -208,7 +200,7 @@ var (
|
|||||||
},
|
},
|
||||||
// Special-purpose TXT records
|
// Special-purpose TXT records
|
||||||
"ip.sslip.io.": {
|
"ip.sslip.io.": {
|
||||||
TXT: ipSslipIo,
|
TXT: TXTIp,
|
||||||
},
|
},
|
||||||
"version.status.sslip.io.": {
|
"version.status.sslip.io.": {
|
||||||
TXT: func(x *Xip, _ net.IP) ([]dnsmessage.TXTResource, error) {
|
TXT: func(x *Xip, _ net.IP) ([]dnsmessage.TXTResource, error) {
|
||||||
@@ -221,7 +213,7 @@ var (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"metrics.status.sslip.io.": {
|
"metrics.status.sslip.io.": {
|
||||||
TXT: metricsSslipIo,
|
TXT: TXTMetrics,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -900,14 +892,25 @@ func (x *Xip) PTRResource(fqdn []byte) *dnsmessage.PTRResource {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SFP records for sslio.io
|
||||||
|
func TXTSslipIoSPF(_ *Xip, _ net.IP) ([]dnsmessage.TXTResource, error) {
|
||||||
|
// Although multiple TXT records with multiple strings are allowed, we're sticking
|
||||||
|
// with a multiple TXT records with a single string apiece because that's what ProtonMail requires
|
||||||
|
// and that's what google.com does.
|
||||||
|
return []dnsmessage.TXTResource{
|
||||||
|
{TXT: []string{"protonmail-verification=ce0ca3f5010aa7a2cf8bcc693778338ffde73e26"}}, // ProtonMail verification; don't delete
|
||||||
|
{TXT: []string{"v=spf1 include:_spf.protonmail.ch mx ~all"}},
|
||||||
|
}, nil // Sender Policy Framework
|
||||||
|
}
|
||||||
|
|
||||||
// when TXT for "ip.sslip.io" is queried, return the IP address of the querier
|
// when TXT for "ip.sslip.io" is queried, return the IP address of the querier
|
||||||
func ipSslipIo(x *Xip, srcAddr net.IP) ([]dnsmessage.TXTResource, error) {
|
func TXTIp(x *Xip, srcAddr net.IP) ([]dnsmessage.TXTResource, error) {
|
||||||
x.Metrics.AnsweredTXTSrcIPQueries++
|
x.Metrics.AnsweredTXTSrcIPQueries++
|
||||||
return []dnsmessage.TXTResource{{TXT: []string{srcAddr.String()}}}, nil
|
return []dnsmessage.TXTResource{{TXT: []string{srcAddr.String()}}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// when TXT for "metrics.sslip.io" is queried, return the cumulative metrics
|
// when TXT for "metrics.sslip.io" is queried, return the cumulative metrics
|
||||||
func metricsSslipIo(x *Xip, _ net.IP) (txtResources []dnsmessage.TXTResource, err error) {
|
func TXTMetrics(x *Xip, _ net.IP) (txtResources []dnsmessage.TXTResource, err error) {
|
||||||
<-x.DnsAmplificationAttackDelay
|
<-x.DnsAmplificationAttackDelay
|
||||||
var metrics []string
|
var metrics []string
|
||||||
uptime := time.Since(x.Metrics.Start)
|
uptime := time.Since(x.Metrics.Start)
|
||||||
|
Reference in New Issue
Block a user