Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
v0.59.0 release (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
ortuman committed Apr 5, 2022
1 parent eb9d512 commit 96b9900
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## 0.59.0 (2022/03/26)

* [FEATURE] Improve k8s compatibility. [#219](https://github.com/ortuman/jackal/pull/219), [#220](https://github.com/ortuman/jackal/pull/220),
* [FEATURE] Improve k8s compatibility. [#219](https://github.com/ortuman/jackal/pull/219), [#220](https://github.com/ortuman/jackal/pull/220),

## 0.58.0 (2022/03/04)

Expand Down
42 changes: 42 additions & 0 deletions pkg/util/net/net.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2022 The jackal Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package net

import (
"fmt"
"net"
"strconv"
"strings"
)

// SRVResolve performs SRV resolution over dns.
func SRVResolve(service, proto, remoteAddr string) ([]string, error) {
var retVal []string

_, addrs, err := net.LookupSRV(service, proto, remoteAddr)
if err != nil {
return nil, err
}
for _, addr := range addrs {
if addr.Target == "." {
continue
}
host := strings.TrimSuffix(addr.Target, ".")
port := strconv.Itoa(int(addr.Port))

retVal = append(retVal, fmt.Sprintf("%s:%s", host, port))
}
return retVal, nil
}

0 comments on commit 96b9900

Please sign in to comment.