Przeglądaj źródła

pcap reset fixes

Tobias von Dewitz 6 lat temu
rodzic
commit
f6de0b4401
2 zmienionych plików z 20 dodań i 18 usunięć
  1. 10 10
      build-rpm-centos7.sh
  2. 10 8
      main.go

+ 10 - 10
build-rpm-centos7.sh

@@ -32,20 +32,20 @@ install -v -m 644 $BINARY.toml $DESTDIR/usr/share/$BINARY/
 
 
 docker run --rm -i -t -v $PWD:/scw -v $PWD/rpmmacros:/root/.rpmmacros -w /scw $DOCKER_IMAGE \
-fpm -s dir -t $PKG_TYPE -C $DESTDIR --name $BINARY \
-  --version $VERSION \
-  --iteration $ITERATION \
-  --description "$DESCR" \
-  --config-files "etc/default/$BINARY" \
-  --config-files "etc/$BINARY/$CONFIG_FILE" \
-  --rpm-trigger-after-install "[]$BINARY: ./after-install-trigger-centos7.sh" \
-  --rpm-trigger-before-uninstall "[]$BINARY: ./before-uninstall-trigger-centos7.sh" \
-  -p $OUTDIR
+  fpm -s dir -t $PKG_TYPE -C $DESTDIR --name $BINARY \
+    --version $VERSION \
+    --iteration $ITERATION \
+    --description "$DESCR" \
+    --config-files "etc/default/$BINARY" \
+    --config-files "etc/$BINARY/$CONFIG_FILE" \
+    --rpm-trigger-after-install "[]$BINARY: ./after-install-trigger-centos7.sh" \
+    --rpm-trigger-before-uninstall "[]$BINARY: ./before-uninstall-trigger-centos7.sh" \
+    -p $OUTDIR
 
 rpm_file="$OUTDIR/$BINARY-$VERSION-$ITERATION.x86_64.rpm"
 
 docker run --rm -i -t -v $PWD:/scw -v $PWD/rpmmacros:/root/.rpmmacros -w /scw $DOCKER_IMAGE \
-/usr/bin/rpm --define "_gpg_name <tobias@scraperwall.com>" --addsign $rpm_file
+  /usr/bin/rpm --define "_gpg_name <tobias@scraperwall.com>" --addsign $rpm_file
 
 ok=$?
 

+ 10 - 8
main.go

@@ -306,9 +306,11 @@ func newLiveCap(device string, filter string, snapshotLen int, promisc bool) (*l
 }
 
 func (lc *liveCap) Setup() error {
-	if lc.packetChan != nil {
-		close(lc.packetChan)
-	}
+	/*
+		if lc.packetChan != nil {
+			close(lc.packetChan)
+		}
+	*/
 
 	if lc.handle != nil {
 		lc.handle.Close()
@@ -350,10 +352,6 @@ func liveCapture() {
 	}(closeChan)
 
 	for {
-		if !config.Quiet {
-			log.Printf("reading incoming HTTP requests on %s %s\n", config.Interface, config.Filter)
-		}
-
 		select {
 		case <-closeChan:
 			livecap.Setup()
@@ -364,6 +362,10 @@ func liveCapture() {
 }
 
 func setupLiveCapture() (chan gopacket.Packet, error) {
+	if !config.Quiet {
+		log.Printf("reading incoming HTTP requests on %s %s\n", config.Interface, config.Filter)
+	}
+
 	// PCAP setup
 	//
 	handle, err := pcap.OpenLive(config.Interface, int32(config.SnapshotLen), config.Promiscuous, timeout)
@@ -371,7 +373,7 @@ func setupLiveCapture() (chan gopacket.Packet, error) {
 		return nil, err
 		// log.Fatal(err)
 	}
-	defer handle.Close()
+	// defer handle.Close()
 
 	err = handle.SetBPFFilter(config.Filter)
 	if err != nil {