Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
13fca023
Commit
13fca023
authored
Dec 06, 2019
by
Zou Nengren
Committed by
corbot[bot]
Dec 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use pkg/reuseport in rest plugins (#3492)
Automatically submitted.
parent
af1fe417
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
plugin/dnstap/dnstapio/io_test.go
plugin/dnstap/dnstapio/io_test.go
+6
-4
plugin/metrics/metrics.go
plugin/metrics/metrics.go
+2
-1
plugin/pkg/dnstest/server.go
plugin/pkg/dnstest/server.go
+3
-1
No files found.
plugin/dnstap/dnstapio/io_test.go
View file @
13fca023
...
@@ -6,6 +6,8 @@ import (
...
@@ -6,6 +6,8 @@ import (
"testing"
"testing"
"time"
"time"
"github.com/coredns/coredns/plugin/pkg/reuseport"
tap
"github.com/dnstap/golang-dnstap"
tap
"github.com/dnstap/golang-dnstap"
fs
"github.com/farsightsec/golang-framestream"
fs
"github.com/farsightsec/golang-framestream"
)
)
...
@@ -55,7 +57,7 @@ func TestTransport(t *testing.T) {
...
@@ -55,7 +57,7 @@ func TestTransport(t *testing.T) {
for
_
,
param
:=
range
transport
{
for
_
,
param
:=
range
transport
{
// Start TCP listener
// Start TCP listener
l
,
err
:=
ne
t
.
Listen
(
param
[
0
],
param
[
1
])
l
,
err
:=
reusepor
t
.
Listen
(
param
[
0
],
param
[
1
])
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot start listener: %s"
,
err
)
t
.
Fatalf
(
"Cannot start listener: %s"
,
err
)
}
}
...
@@ -82,7 +84,7 @@ func TestRace(t *testing.T) {
...
@@ -82,7 +84,7 @@ func TestRace(t *testing.T) {
count
:=
10
count
:=
10
// Start TCP listener
// Start TCP listener
l
,
err
:=
ne
t
.
Listen
(
"tcp"
,
endpointTCP
)
l
,
err
:=
reusepor
t
.
Listen
(
"tcp"
,
endpointTCP
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot start listener: %s"
,
err
)
t
.
Fatalf
(
"Cannot start listener: %s"
,
err
)
}
}
...
@@ -115,7 +117,7 @@ func TestReconnect(t *testing.T) {
...
@@ -115,7 +117,7 @@ func TestReconnect(t *testing.T) {
count
:=
5
count
:=
5
// Start TCP listener
// Start TCP listener
l
,
err
:=
ne
t
.
Listen
(
"tcp"
,
endpointTCP
)
l
,
err
:=
reusepor
t
.
Listen
(
"tcp"
,
endpointTCP
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot start listener: %s"
,
err
)
t
.
Fatalf
(
"Cannot start listener: %s"
,
err
)
}
}
...
@@ -141,7 +143,7 @@ func TestReconnect(t *testing.T) {
...
@@ -141,7 +143,7 @@ func TestReconnect(t *testing.T) {
l
.
Close
()
l
.
Close
()
// And start TCP listener again on the same port
// And start TCP listener again on the same port
l
,
err
=
ne
t
.
Listen
(
"tcp"
,
addr
)
l
,
err
=
reusepor
t
.
Listen
(
"tcp"
,
addr
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot start listener: %s"
,
err
)
t
.
Fatalf
(
"Cannot start listener: %s"
,
err
)
}
}
...
...
plugin/metrics/metrics.go
View file @
13fca023
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/metrics/vars"
"github.com/coredns/coredns/plugin/metrics/vars"
"github.com/coredns/coredns/plugin/pkg/reuseport"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/client_golang/prometheus/promhttp"
...
@@ -95,7 +96,7 @@ func (m *Metrics) ZoneNames() []string {
...
@@ -95,7 +96,7 @@ func (m *Metrics) ZoneNames() []string {
// OnStartup sets up the metrics on startup.
// OnStartup sets up the metrics on startup.
func
(
m
*
Metrics
)
OnStartup
()
error
{
func
(
m
*
Metrics
)
OnStartup
()
error
{
ln
,
err
:=
ne
t
.
Listen
(
"tcp"
,
m
.
Addr
)
ln
,
err
:=
reusepor
t
.
Listen
(
"tcp"
,
m
.
Addr
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorf
(
"Failed to start metrics handler: %s"
,
err
)
log
.
Errorf
(
"Failed to start metrics handler: %s"
,
err
)
return
err
return
err
...
...
plugin/pkg/dnstest/server.go
View file @
13fca023
...
@@ -3,6 +3,8 @@ package dnstest
...
@@ -3,6 +3,8 @@ package dnstest
import
(
import
(
"net"
"net"
"github.com/coredns/coredns/plugin/pkg/reuseport"
"github.com/miekg/dns"
"github.com/miekg/dns"
)
)
...
@@ -27,7 +29,7 @@ func NewServer(f dns.HandlerFunc) *Server {
...
@@ -27,7 +29,7 @@ func NewServer(f dns.HandlerFunc) *Server {
s2
:=
&
dns
.
Server
{}
// tcp
s2
:=
&
dns
.
Server
{}
// tcp
for
i
:=
0
;
i
<
5
;
i
++
{
// 5 attempts
for
i
:=
0
;
i
<
5
;
i
++
{
// 5 attempts
s2
.
Listener
,
_
=
ne
t
.
Listen
(
"tcp"
,
":0"
)
s2
.
Listener
,
_
=
reusepor
t
.
Listen
(
"tcp"
,
":0"
)
if
s2
.
Listener
==
nil
{
if
s2
.
Listener
==
nil
{
continue
continue
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment