Browse Source

pcap reset fixes

Tobias von Dewitz 6 years ago
parent
commit
f6de0b4401
2 changed files with 20 additions and 18 deletions
  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 \
 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"
 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 \
 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=$?
 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 {
 func (lc *liveCap) Setup() error {
-	if lc.packetChan != nil {
-		close(lc.packetChan)
-	}
+	/*
+		if lc.packetChan != nil {
+			close(lc.packetChan)
+		}
+	*/
 
 
 	if lc.handle != nil {
 	if lc.handle != nil {
 		lc.handle.Close()
 		lc.handle.Close()
@@ -350,10 +352,6 @@ func liveCapture() {
 	}(closeChan)
 	}(closeChan)
 
 
 	for {
 	for {
-		if !config.Quiet {
-			log.Printf("reading incoming HTTP requests on %s %s\n", config.Interface, config.Filter)
-		}
-
 		select {
 		select {
 		case <-closeChan:
 		case <-closeChan:
 			livecap.Setup()
 			livecap.Setup()
@@ -364,6 +362,10 @@ func liveCapture() {
 }
 }
 
 
 func setupLiveCapture() (chan gopacket.Packet, error) {
 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
 	// PCAP setup
 	//
 	//
 	handle, err := pcap.OpenLive(config.Interface, int32(config.SnapshotLen), config.Promiscuous, timeout)
 	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
 		return nil, err
 		// log.Fatal(err)
 		// log.Fatal(err)
 	}
 	}
-	defer handle.Close()
+	// defer handle.Close()
 
 
 	err = handle.SetBPFFilter(config.Filter)
 	err = handle.SetBPFFilter(config.Filter)
 	if err != nil {
 	if err != nil {