@@ -14,7 +14,7 @@ import (
14
14
"time"
15
15
)
16
16
17
- const AppVersion = "0.54 "
17
+ const AppVersion = "0.55 "
18
18
19
19
var localAddr * string = flag .String ("l" , ":9060" , "Local HEP listening address" )
20
20
var remoteAddr * string = flag .String ("r" , "192.168.2.2:9060" , "Remote HEP address" )
@@ -68,16 +68,15 @@ func initLoopbackConn(wg *sync.WaitGroup) {
68
68
69
69
}
70
70
71
- func copyHEPbufftoFile (inbytes [] byte , file string ) (int64 , error ) {
71
+ func copyHEPbufftoFile (inbytes * net. TCPConn , file string ) (int64 , error ) {
72
72
73
73
destination , err := os .OpenFile (file , os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0666 )
74
74
if err != nil {
75
75
fmt .Println ("Open HEP file error" , err )
76
76
}
77
77
78
78
defer destination .Close ()
79
- nBytes , err := destination .Write (inbytes )
80
-
79
+ nBytes , err := io .Copy (destination , inbytes )
81
80
if err != nil {
82
81
log .Println ("||-->X File Send HEP from buffer to file error" , err )
83
82
} else {
@@ -168,7 +167,7 @@ func proxyConn(conn *net.TCPConn) {
168
167
for _ , ipf := range filterIPs {
169
168
if ((hepPkt .SrcIP == string (ipf ) || hepPkt .DstIP == string (ipf )) && * IPfilter != "" && * IPfilterAction == "pass" ) || (* IPfilter == "" || (hepPkt .SrcIP != string (ipf ) || hepPkt .DstIP != string (ipf )) && * IPfilter != "" && * IPfilterAction == "reject" ) {
170
169
171
- go copyHEPbufftoFile (buf [: data ] , HEPsavefile )
170
+ go copyHEPbufftoFile (conn , HEPsavefile )
172
171
}
173
172
}
174
173
@@ -237,7 +236,7 @@ func proxyConn(conn *net.TCPConn) {
237
236
if _ , err_HEPout := fmt .Fprint (rConn , string (buf [:data ])); err_HEPout != nil {
238
237
log .Println ("||--> Sending HEP OUT error:" , err_HEPout )
239
238
// rb := bytes.NewReader(buf[:data])
240
- go copyHEPbufftoFile (buf [: data ] , HEPsavefile )
239
+ go copyHEPbufftoFile (conn , HEPsavefile )
241
240
accepted = true
242
241
return
243
242
} else {
@@ -289,7 +288,7 @@ func proxyConn(conn *net.TCPConn) {
289
288
if _ , err_HEPout := fmt .Fprint (rConn , string (buf [:data ])); err_HEPout != nil {
290
289
log .Println ("||--> Sending HEP OUT error:" , err_HEPout )
291
290
//rb := bytes.NewReader(buf[:data])
292
- go copyHEPbufftoFile (buf [: data ] , HEPsavefile )
291
+ go copyHEPbufftoFile (conn , HEPsavefile )
293
292
return
294
293
} else {
295
294
if * Debug == "on" {
@@ -303,7 +302,7 @@ func proxyConn(conn *net.TCPConn) {
303
302
if _ , err_HEPout := fmt .Fprint (rConn , string (buf [:data ])); err_HEPout != nil {
304
303
log .Println ("||--> Sending HEP OUT error:" , err_HEPout )
305
304
// rb := bytes.NewReader(buf[:data])
306
- go copyHEPbufftoFile (buf [: data ] , HEPsavefile )
305
+ go copyHEPbufftoFile (conn , HEPsavefile )
307
306
return
308
307
} else {
309
308
if * Debug == "on" {
0 commit comments