From 0e767ccb3ac913b76fdebf2ef2a0901419802009 Mon Sep 17 00:00:00 2001 From: Mircea-Pavel ANTON Date: Sat, 26 Oct 2024 20:24:30 +0000 Subject: [PATCH 1/7] add support for MX records --- internal/mikrotik/record.go | 63 +++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/internal/mikrotik/record.go b/internal/mikrotik/record.go index e4604bf..ec85fa5 100644 --- a/internal/mikrotik/record.go +++ b/internal/mikrotik/record.go @@ -32,9 +32,9 @@ type DNSRecord struct { CName string `json:"cname,omitempty"` // CNAME -> endpoint.Targets[0] Text string `json:"text,omitempty"` // TXT -> endpoint.Targets[0] + MXExchange string `json:"mx-exchange,omitempty"` // MX -> provider-specific + MXPreference string `json:"mx-preference,omitempty"` // MX -> provider-specific // Additional fields for other record types that are not currently supported - // MXExchange string `json:"mx-exchange,omitempty"` // MX -> provider-specific - // MXPreference string `json:"mx-preference,omitempty"` // MX -> provider-specific // SrvPort string `json:"srv-port,omitempty"` // SRV -> provider-specific // SrvTarget string `json:"srv-target,omitempty"` // SRV -> provider-specific // SrvPriority string `json:"srv-priority,omitempty"` // SRV -> provider-specific @@ -100,6 +100,16 @@ func NewDNSRecord(endpoint *endpoint.Endpoint) (*DNSRecord, error) { record.Text = endpoint.Targets[0] log.Debugf("Text set to: %s", record.Text) + case "MX": + preference, exchange, err := parseMX(endpoint.Targets[0]) + if err != nil { + return nil, err + } + record.MXPreference = fmt.Sprintf("%v", preference) + log.Debugf("MX preference set to: %s", record.MXPreference) + record.MXExchange = exchange + log.Debugf("MX exchange set to: %s", record.MXExchange) + default: return nil, fmt.Errorf("unsupported DNS type: %s", endpoint.RecordType) } @@ -192,6 +202,17 @@ func (r *DNSRecord) toExternalDNSEndpoint() (*endpoint.Endpoint, error) { ep.Targets = endpoint.NewTargets(r.Text) log.Debugf("Text set to: %s", r.Text) + case "MX": + if err := validateDomain(r.MXExchange); err != nil { + return nil, err + } + if err := validateMXPreference(r.MXPreference); err != nil { + return nil, err + } + ep.Targets = endpoint.NewTargets(fmt.Sprintf("%s %s", r.MXPreference, r.MXExchange)) + log.Debugf("MX preference set to: %s", r.MXPreference) + log.Debugf("MX exchange set to: %s", r.MXExchange) + default: return nil, fmt.Errorf("unsupported DNS type: %s", ep.RecordType) } @@ -395,3 +416,41 @@ func validateDomain(domain string) error { return nil } + +// validateMXPreference checks if the provided MX preference is valid. +func validateMXPreference(preference string) error { + if preference == "" { + return fmt.Errorf("MX preference cannot be empty") + } + preferenceVal, err := strconv.Atoi(preference) + if err != nil { + return fmt.Errorf("invalid MX preference value: %s . Value cannot be converrted to int", preference) + } + + if preferenceVal < 0 || preferenceVal > 65535 { + return fmt.Errorf("invalid MX preference value: %s . Value must be between 0 and 65535", preference) + } + return nil +} + +// parseMX parses and validates an MX record +func parseMX(data string) (string, string, error) { + data_split := strings.Split(data, " ") + if len(data_split) != 2 { + return "", "", fmt.Errorf("malformed MX record %s", data) + } + + // Extract and Validate MX Preference + preference := data_split[0] + if err := validateMXPreference(preference); err != nil { + return "", "", err + } + + // Extract and Validate MX Exchange + exchange := data_split[1] + if err := validateDomain(exchange); err != nil { + return "", "", err + } + + return preference, exchange, nil +} From 40dc49295a25a4c4f4070d4661da5f23bb28c9d9 Mon Sep 17 00:00:00 2001 From: Mircea-Pavel ANTON Date: Sat, 26 Oct 2024 20:24:36 +0000 Subject: [PATCH 2/7] add test cases for MX records --- internal/mikrotik/record_test.go | 201 +++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/internal/mikrotik/record_test.go b/internal/mikrotik/record_test.go index a5b2393..270dc8d 100644 --- a/internal/mikrotik/record_test.go +++ b/internal/mikrotik/record_test.go @@ -99,6 +99,29 @@ func TestValidateDomain(t *testing.T) { } } +func TestValidateMXPreference(t *testing.T) { + tests := []struct { + name string + preference string + expectError bool + }{ + {"Valid MX preference", "10", false}, + {"Empty MX preference", "", true}, + {"Negative MX preference", "-10", true}, + {"Too high MX preference", "70000", true}, + {"Not a number", "abc", true}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := validateMXPreference(tt.preference) + if (err != nil) != tt.expectError { + t.Errorf("expected error: %v, got: %v for MX preference: %s", tt.expectError, err, tt.preference) + } + }) + } +} + // ================================================================================================ // Test TTL Conversion Functions // ================================================================================================ @@ -355,6 +378,111 @@ func TestDNSRecordToExternalDNSEndpoint(t *testing.T) { expectError: true, }, + // =============================================================== + // MX RECORD TEST CASES + // =============================================================== + { + name: "Valid MX record", + record: &DNSRecord{ + Name: "mx.example.com", + Type: "MX", + MXExchange: "mailhost1.example.com", + MXPreference: "10", + TTL: "10m", + }, + expected: &endpoint.Endpoint{ + DNSName: "mx.example.com", + RecordType: "MX", + Targets: endpoint.NewTargets("10 mailhost1.example.com"), + RecordTTL: endpoint.TTL(600), + }, + expectError: false, + }, + { + name: "Invalid MX record (empty preference)", + record: &DNSRecord{ + Name: "invalid.example.com", + Type: "MX", + MXExchange: "mailhost1.example.com", + MXPreference: "", + TTL: "10m", + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (negative preference)", + record: &DNSRecord{ + Name: "invalid.example.com", + Type: "MX", + MXExchange: "mailhost1.example.com", + MXPreference: "-10", + TTL: "10m", + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (too large preference)", + record: &DNSRecord{ + Name: "invalid.example.com", + Type: "MX", + MXExchange: "mailhost1.example.com", + MXPreference: "70000", + TTL: "10m", + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (non-numeric preference)", + record: &DNSRecord{ + Name: "invalid.example.com", + Type: "MX", + MXExchange: "mailhost1.example.com", + MXPreference: "invalid", + TTL: "10m", + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (empty exchange)", + record: &DNSRecord{ + Name: "invalid.example.com", + Type: "MX", + MXExchange: "", + MXPreference: "1", + TTL: "10m", + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (exchange missing TLD)", + record: &DNSRecord{ + Name: "invalid.example.com", + Type: "MX", + MXExchange: "invalid_domain", + MXPreference: "10", + TTL: "10m", + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (malformed domain)", + record: &DNSRecord{ + Name: "invalid.example.com", + Type: "MX", + MXExchange: "sub....domain.com", + MXPreference: "10", + TTL: "10m", + }, + expected: nil, + expectError: true, + }, + // =============================================================== // PROVIDER-SPECIFIC DATA TEST CASES // =============================================================== @@ -708,6 +836,79 @@ func TestExternalDNSEndpointToDNSRecord(t *testing.T) { expectError: true, }, + { + name: "Valid MX record", + endpoint: &endpoint.Endpoint{ + DNSName: "mx.example.com", + RecordType: "MX", + Targets: endpoint.NewTargets("10 mailhost1.example.com"), + RecordTTL: endpoint.TTL(600), + }, + expected: &DNSRecord{ + Name: "mx.example.com", + Type: "MX", + MXExchange: "mailhost1.example.com", + MXPreference: "10", + TTL: "10m", + }, + expectError: false, + }, + { + name: "Invalid MX record (empty preference)", + endpoint: &endpoint.Endpoint{ + DNSName: "mx.example.com", + RecordType: "MX", + Targets: endpoint.NewTargets(" mailhost1.example.com"), + RecordTTL: endpoint.TTL(600), + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (negative preference)", + endpoint: &endpoint.Endpoint{ + DNSName: "mx.example.com", + RecordType: "MX", + Targets: endpoint.NewTargets("-10 mailhost1.example.com"), + RecordTTL: endpoint.TTL(600), + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (too large preference)", + endpoint: &endpoint.Endpoint{ + DNSName: "mx.example.com", + RecordType: "MX", + Targets: endpoint.NewTargets("70000 mailhost1.example.com"), + RecordTTL: endpoint.TTL(600), + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (non-numeric preference)", + endpoint: &endpoint.Endpoint{ + DNSName: "mx.example.com", + RecordType: "MX", + Targets: endpoint.NewTargets("123 "), + RecordTTL: endpoint.TTL(600), + }, + expected: nil, + expectError: true, + }, + { + name: "Invalid MX record (malformed exchange)", + endpoint: &endpoint.Endpoint{ + DNSName: "mx.example.com", + RecordType: "MX", + Targets: endpoint.NewTargets("123 sub....domain.com"), + RecordTTL: endpoint.TTL(600), + }, + expected: nil, + expectError: true, + }, + // =============================================================== // PROVIDER-SPECIFIC DATA TEST CASES // =============================================================== From 5cea21cf1e95e089c2cc541136a1135c258209a8 Mon Sep 17 00:00:00 2001 From: Mircea-Pavel ANTON Date: Sat, 26 Oct 2024 20:33:01 +0000 Subject: [PATCH 3/7] go mod tidy --- go.sum | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/go.sum b/go.sum index ffd601c..d1a56ef 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,9 @@ -github.com/aws/aws-sdk-go v1.53.3 h1:xv0iGCCLdf6ZtlLPMCBjm+tU9UBLP5hXnSqnbKFYmto= -github.com/aws/aws-sdk-go v1.53.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU= github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/caarlos0/env/v11 v11.2.2 h1:95fApNrUyueipoZN/EhA8mMxiNxrBwDa+oAZrMWl3Kg= github.com/caarlos0/env/v11 v11.2.2/go.mod h1:JBfcdeQiBoI3Zh1QRAWfe+tpiNTmDtcCj/hHHHMx0vc= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -19,8 +15,6 @@ github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -45,6 +39,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -55,24 +51,16 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= -github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= -github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= -github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -97,8 +85,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -108,14 +94,10 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -126,8 +108,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -141,20 +121,12 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U= -k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= k8s.io/apimachinery v0.31.0 h1:m9jOiSr3FoSSL5WO9bjm1n6B9KROYYgNZOb4tyZ1lBc= k8s.io/apimachinery v0.31.0/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= -k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= -k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/utils v0.0.0-20240423183400-0849a56e8f22 h1:ao5hUqGhsqdm+bYbjH/pRkCs0unBGe9UyDahzs9zQzQ= -k8s.io/utils v0.0.0-20240423183400-0849a56e8f22/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/external-dns v0.14.2 h1:j7rYtQqDAxYfN9N1/BZcRdzUBRsnZp4tZcuZ75ekTlc= -sigs.k8s.io/external-dns v0.14.2/go.mod h1:GTFER2cqUxkSpYNzzkge8USXp1wJmxqWwpdXr2lYdik= sigs.k8s.io/external-dns v0.15.0 h1:4NCSLHONsTmJXD8KReb4hubSz9Cx4goCHz3Dl+pGR+Q= sigs.k8s.io/external-dns v0.15.0/go.mod h1:QdocdJu3mk9l4u80fu992lZEKqKd1130h17yNisIC78= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= From 35158b4b6cfb9bd68ed76937af09fbe46ec5bde2 Mon Sep 17 00:00:00 2001 From: Mircea-Pavel ANTON Date: Sat, 26 Oct 2024 20:33:10 +0000 Subject: [PATCH 4/7] update test deployment values --- deploy/values.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deploy/values.yaml b/deploy/values.yaml index ecdf330..1b722d2 100644 --- a/deploy/values.yaml +++ b/deploy/values.yaml @@ -14,7 +14,7 @@ provider: webhook: image: repository: ghcr.io/mirceanton/external-dns-provider-mikrotik - tag: sha-36f6f8d + tag: pr-95 pullPolicy: Always env: - name: LOG_FORMAT @@ -65,6 +65,11 @@ extraArgs: - --source=crd - --crd-source-apiversion=externaldns.k8s.io/v1alpha1 - --crd-source-kind=DNSEndpoint + - --managed-record-types=A + - --managed-record-types=AAAA + - --managed-record-types=CNAME + - --managed-record-types=TXT + - --managed-record-types=MX rbac: create: true From a331339ce03d444bcc8fd980c7cb9f30cbd05687 Mon Sep 17 00:00:00 2001 From: Mircea-Pavel ANTON Date: Sat, 26 Oct 2024 20:42:00 +0000 Subject: [PATCH 5/7] update example env --- .env.example | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.env.example b/.env.example index fb2dcef..eb2f6b6 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,4 @@ -MIKROTIK_HOST = "" -MIKROTIK_PORT = 443 +MIKROTIK_BASEURL = "192.168.88.1:443" MIKROTIK_USERNAME = "" MIKROTIK_PASSWORD = "" From 647056a71b4315e956d204a0d3ee24370a0bbfc4 Mon Sep 17 00:00:00 2001 From: Mircea-Pavel ANTON Date: Sat, 26 Oct 2024 21:34:00 +0000 Subject: [PATCH 6/7] fix env vars --- deploy/values.yaml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/deploy/values.yaml b/deploy/values.yaml index 1b722d2..93754f2 100644 --- a/deploy/values.yaml +++ b/deploy/values.yaml @@ -21,16 +21,11 @@ provider: value: json - name: LOG_LEVEL value: debug - - name: MIKROTIK_HOST + - name: MIKROTIK_BASEURL valueFrom: secretKeyRef: name: mikrotik-credentials - key: MIKROTIK_HOST - - name: MIKROTIK_PORT - valueFrom: - secretKeyRef: - name: mikrotik-credentials - key: MIKROTIK_PORT + key: MIKROTIK_BASEURL - name: MIKROTIK_USERNAME valueFrom: secretKeyRef: @@ -50,13 +45,13 @@ provider: livenessProbe: httpGet: path: /healthz - port: http-wh-metrics + port: http-webhook initialDelaySeconds: 10 timeoutSeconds: 5 readinessProbe: httpGet: path: /readyz - port: http-wh-metrics + port: http-webhook initialDelaySeconds: 10 timeoutSeconds: 5 From f5809c8d861681bbaa7a839080dd5cdfd6767592 Mon Sep 17 00:00:00 2001 From: Mircea-Pavel ANTON Date: Sat, 26 Oct 2024 21:34:06 +0000 Subject: [PATCH 7/7] update example --- deploy/records/mx-record.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy/records/mx-record.yaml b/deploy/records/mx-record.yaml index 24b880b..6df7452 100644 --- a/deploy/records/mx-record.yaml +++ b/deploy/records/mx-record.yaml @@ -10,4 +10,3 @@ spec: recordType: MX targets: - 10 mailhost1.example.com - - 20 mailhost2.example.com