Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
L
logstash-forwarder
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
LaaS
logstash-forwarder
Commits
443f0d9b
Commit
443f0d9b
authored
Nov 20, 2013
by
Jordan Sissel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actually dns lookup the host, not the host:port. Silly me!
parent
fdba43b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
publisher1.go
publisher1.go
+14
-3
No files found.
publisher1.go
View file @
443f0d9b
...
...
@@ -15,9 +15,13 @@ import (
"time"
"compress/zlib"
"strconv"
"regexp"
"fmt"
)
var
hostname
string
var
hostport_re
,
_
=
regexp
.
Compile
(
"^(.+):([0-9]+)$"
)
func
init
()
{
log
.
Printf
(
"publisher init
\n
"
)
hostname
,
_
=
os
.
Hostname
()
...
...
@@ -142,7 +146,13 @@ func connect(config *NetworkConfig) (socket *tls.Conn) {
for
{
// Pick a random server from the list.
host
:=
config
.
Servers
[
rand
.
Int
()
%
len
(
config
.
Servers
)]
hostport
:=
config
.
Servers
[
rand
.
Int
()
%
len
(
config
.
Servers
)]
submatch
:=
hostport_re
.
FindSubmatch
([]
byte
(
hostport
))
if
submatch
==
nil
{
log
.
Fatalf
(
"Invalid host:port given: %s"
,
hostport
)
}
host
:=
string
(
submatch
[
1
])
port
:=
string
(
submatch
[
2
])
addresses
,
err
:=
net
.
LookupHost
(
host
)
if
err
!=
nil
{
...
...
@@ -152,10 +162,11 @@ func connect(config *NetworkConfig) (socket *tls.Conn) {
}
address
:=
addresses
[
rand
.
Int
()
%
len
(
addresses
)]
addressport
:=
fmt
.
Sprintf
(
"%s:%s"
,
address
,
port
)
log
.
Printf
(
"Connecting to %s (%s)
\n
"
,
address
,
host
)
log
.
Printf
(
"Connecting to %s (%s)
\n
"
,
address
port
,
host
)
tcpsocket
,
err
:=
net
.
DialTimeout
(
"tcp"
,
address
,
config
.
timeout
)
tcpsocket
,
err
:=
net
.
DialTimeout
(
"tcp"
,
address
port
,
config
.
timeout
)
if
err
!=
nil
{
log
.
Printf
(
"Failure connecting to %s: %s
\n
"
,
address
,
err
)
time
.
Sleep
(
1
*
time
.
Second
)
...
...
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