chg: [main] reuse existing tcp connection
parent
d52c02f8de
commit
ab248fa3ad
|
@ -266,7 +266,7 @@ func d4loadConfig(d4 *d4S) bool {
|
||||||
}
|
}
|
||||||
if (*d4).conf.source == "d4server" {
|
if (*d4).conf.source == "d4server" {
|
||||||
// Parse Input Redis Config
|
// Parse Input Redis Config
|
||||||
tmp := config.ReadConfigFile(*confdir, "redis_d4")
|
tmp := string(readConfFile(d4, "redis_d4"))
|
||||||
ss := strings.Split(string(tmp), "/")
|
ss := strings.Split(string(tmp), "/")
|
||||||
if len(ss) <= 1 {
|
if len(ss) <= 1 {
|
||||||
log.Fatal("Missing Database in Redis input config: should be host:port/database_name")
|
log.Fatal("Missing Database in Redis input config: should be host:port/database_name")
|
||||||
|
@ -414,33 +414,40 @@ func setReaderWriters(d4 *d4S) bool {
|
||||||
}
|
}
|
||||||
isn, dstnet := config.IsNet((*d4).conf.destination)
|
isn, dstnet := config.IsNet((*d4).conf.destination)
|
||||||
if isn {
|
if isn {
|
||||||
dial := net.Dialer{
|
// First, we test whether a usable connection already exist
|
||||||
Timeout: (*d4).ct,
|
// (case where the reader run out of data)
|
||||||
KeepAlive: (*d4).cka,
|
switch (*d4).dst.w.(type){
|
||||||
FallbackDelay: 0,
|
case net.Conn:
|
||||||
}
|
logger.Println("Reusing previous tcp connection.")
|
||||||
tlsc := tls.Config{
|
default:
|
||||||
InsecureSkipVerify: true,
|
dial := net.Dialer{
|
||||||
}
|
Timeout: (*d4).ct,
|
||||||
if (*d4).cc {
|
KeepAlive: (*d4).cka,
|
||||||
tlsc = tls.Config{
|
FallbackDelay: 0,
|
||||||
InsecureSkipVerify: false,
|
|
||||||
RootCAs: &(*d4).ca,
|
|
||||||
}
|
}
|
||||||
}
|
tlsc := tls.Config{
|
||||||
if (*d4).ce == true {
|
InsecureSkipVerify: true,
|
||||||
conn, errc := tls.DialWithDialer(&dial, "tcp", dstnet, &tlsc)
|
|
||||||
if errc != nil {
|
|
||||||
logger.Println(errc)
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
(*d4).dst = newD4Writer(conn, (*d4).conf.key)
|
if (*d4).cc {
|
||||||
} else {
|
tlsc = tls.Config{
|
||||||
conn, errc := dial.Dial("tcp", dstnet)
|
InsecureSkipVerify: false,
|
||||||
if errc != nil {
|
RootCAs: &(*d4).ca,
|
||||||
return false
|
}
|
||||||
|
}
|
||||||
|
if (*d4).ce == true {
|
||||||
|
conn, errc := tls.DialWithDialer(&dial, "tcp", dstnet, &tlsc)
|
||||||
|
if errc != nil {
|
||||||
|
logger.Println(errc)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
(*d4).dst = newD4Writer(conn, (*d4).conf.key)
|
||||||
|
} else {
|
||||||
|
conn, errc := dial.Dial("tcp", dstnet)
|
||||||
|
if errc != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
(*d4).dst = newD4Writer(conn, (*d4).conf.key)
|
||||||
}
|
}
|
||||||
(*d4).dst = newD4Writer(conn, (*d4).conf.key)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (*d4).conf.destination {
|
switch (*d4).conf.destination {
|
||||||
|
@ -466,7 +473,7 @@ func generateUUIDv4() []byte {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
logger.Println(fmt.Sprintf("UUIDv4: %s\n", uuid))
|
logger.Println(fmt.Sprintf("UUIDv4: %s", uuid))
|
||||||
return uuid.Bytes()
|
return uuid.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue