feat(action): accept PTR-style names in reverse lookup
Co-authored-by: Virgil <virgil@lethean.io>
This commit is contained in:
parent
8b6fcf0946
commit
1c91ff091f
2 changed files with 18 additions and 1 deletions
|
|
@ -291,7 +291,7 @@ func (service *Service) handleResolveAll(ctx context.Context, values map[string]
|
|||
|
||||
func (service *Service) handleReverseLookup(ctx context.Context, values map[string]any) (any, bool, error) {
|
||||
_ = ctx
|
||||
ip, err := stringActionValueFromKeys(values, actionArgIP, actionArgAddress)
|
||||
ip, err := stringActionValueFromKeys(values, actionArgIP, actionArgAddress, actionArgName, actionArgHost, actionArgHostName)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3560,6 +3560,23 @@ func TestServiceHandleActionReverseHealthServeAndDiscover(t *testing.T) {
|
|||
t.Fatalf("unexpected reverse result: %#v", reverse.Names)
|
||||
}
|
||||
|
||||
ptrPayload, ok, err := service.HandleAction(ActionReverse, map[string]any{
|
||||
"name": "20.10.10.10.in-addr.arpa.",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected reverse action error for PTR name: %v", err)
|
||||
}
|
||||
if !ok {
|
||||
t.Fatal("expected reverse action to accept PTR-style names")
|
||||
}
|
||||
ptr, ok := ptrPayload.(ReverseLookupResult)
|
||||
if !ok {
|
||||
t.Fatalf("expected ReverseLookupResult payload for PTR name, got %T", ptrPayload)
|
||||
}
|
||||
if len(ptr.Names) != 1 || ptr.Names[0] != "gateway.charon.lthn" {
|
||||
t.Fatalf("unexpected PTR reverse result: %#v", ptr.Names)
|
||||
}
|
||||
|
||||
healthPayload, ok, err := service.HandleAction(ActionHealth, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected health action error: %v", err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue