From 3be807754ef9a451ee1f55b70d3e973516909f53 Mon Sep 17 00:00:00 2001 From: lonord Date: Sun, 26 Aug 2018 22:51:35 +0800 Subject: [PATCH] prune unused code & add header to sse response to support nginx proxy --- .gitignore | 1 + app/webservice_netspeed.go | 4 ++- dnsmasq/dnsmasq_test.go | 52 -------------------------------------- 3 files changed, 4 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index c46d46d..72dbc30 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +.idea/ dist/ \ No newline at end of file diff --git a/app/webservice_netspeed.go b/app/webservice_netspeed.go index d081304..f825c91 100644 --- a/app/webservice_netspeed.go +++ b/app/webservice_netspeed.go @@ -20,7 +20,9 @@ type netSpeedService struct { func newNetSpeedService(action *MainAction) *netSpeedService { return &netSpeedService{ - sse: sse.NewService(), + sse: sse.NewServiceWithOption(sse.Option{ + Headers: map[string]string{"X-Accel-Buffering": "no"}, + }), action: action, } } diff --git a/dnsmasq/dnsmasq_test.go b/dnsmasq/dnsmasq_test.go index ec3e680..0a20dbe 100644 --- a/dnsmasq/dnsmasq_test.go +++ b/dnsmasq/dnsmasq_test.go @@ -24,58 +24,6 @@ func TestCollectInternalArgs(t *testing.T) { } } -func TestConvertLeases(t *testing.T) { - leases := convertLeases(leasesContent) - if len(leases) != 6 { - t.Errorf("leases length dismatch") - } - if leases[0].ExpireTimeStamp != 1524448523 { - t.Errorf("ExpireTimeStamp dismatch") - } - if leases[0].MACAddr != "00:0e:c6:a6:0c:99" { - t.Errorf("MACAddr dismatch") - } - if leases[0].IPAddr != "192.168.4.127" { - t.Errorf("IPAddr dismatch") - } - if leases[0].HostName != "lmbp" { - t.Errorf("HostName dismatch") - } - if leases[0].ClientID != "01:00:0e:c6:a6:0c:99" { - t.Errorf("ClientID dismatch") - } - if leases[1].ExpireTimeStamp != 1528766444 { - t.Errorf("ExpireTimeStamp dismatch") - } - if leases[1].MACAddr != "dc:a9:04:86:fd:99" { - t.Errorf("MACAddr dismatch") - } - if leases[1].IPAddr != "192.168.4.90" { - t.Errorf("IPAddr dismatch") - } - if leases[1].HostName != "*" { - t.Errorf("HostName dismatch") - } - if leases[1].ClientID != "01:dc:a9:04:86:fd:99" { - t.Errorf("ClientID dismatch") - } - if leases[4].ExpireTimeStamp != 1528766261 { - t.Errorf("ExpireTimeStamp dismatch") - } - if leases[4].MACAddr != "60:6b:ff:25:29:99" { - t.Errorf("MACAddr dismatch") - } - if leases[4].IPAddr != "192.168.4.92" { - t.Errorf("IPAddr dismatch") - } - if leases[4].HostName != "*" { - t.Errorf("HostName dismatch") - } - if leases[4].ClientID != "*" { - t.Errorf("ClientID dismatch") - } -} - const dsContent = `. IN DS 19036 8 2 49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5 `