pre-pre-pre-build of packets
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								installed.db
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								installed.db
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										22
									
								
								src/go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/go.mod
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
module packets
 | 
			
		||||
 | 
			
		||||
go 1.24.4
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	github.com/ulikunitz/xz v0.5.12
 | 
			
		||||
	golang.org/x/net v0.41.0
 | 
			
		||||
	modernc.org/sqlite v1.38.0
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	github.com/dustin/go-humanize v1.0.1 // indirect
 | 
			
		||||
	github.com/google/uuid v1.6.0 // indirect
 | 
			
		||||
	github.com/mattn/go-isatty v0.0.20 // indirect
 | 
			
		||||
	github.com/ncruces/go-strftime v0.1.9 // indirect
 | 
			
		||||
	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
 | 
			
		||||
	golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
 | 
			
		||||
	golang.org/x/sys v0.33.0 // indirect
 | 
			
		||||
	modernc.org/libc v1.65.10 // indirect
 | 
			
		||||
	modernc.org/mathutil v1.7.1 // indirect
 | 
			
		||||
	modernc.org/memory v1.11.0 // indirect
 | 
			
		||||
)
 | 
			
		||||
							
								
								
									
										31
									
								
								src/go.sum
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/go.sum
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
 | 
			
		||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
 | 
			
		||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 | 
			
		||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 | 
			
		||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 | 
			
		||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
 | 
			
		||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
 | 
			
		||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
 | 
			
		||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
 | 
			
		||||
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
 | 
			
		||||
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
 | 
			
		||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
 | 
			
		||||
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
 | 
			
		||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
 | 
			
		||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
 | 
			
		||||
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
 | 
			
		||||
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
 | 
			
		||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
			
		||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
 | 
			
		||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
 | 
			
		||||
modernc.org/libc v1.65.10 h1:ZwEk8+jhW7qBjHIT+wd0d9VjitRyQef9BnzlzGwMODc=
 | 
			
		||||
modernc.org/libc v1.65.10/go.mod h1:StFvYpx7i/mXtBAfVOjaU0PWZOvIRoZSgXhrwXzr8Po=
 | 
			
		||||
modernc.org/libc v1.66.0 h1:eoFuDb1ozurUY5WSWlgvxHp0FuL+AncMwNjFqGYMJPQ=
 | 
			
		||||
modernc.org/libc v1.66.0/go.mod h1:AiZxInURfEJx516LqEaFcrC+X38rt9G7+8ojIXQKHbo=
 | 
			
		||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
 | 
			
		||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
 | 
			
		||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
 | 
			
		||||
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
 | 
			
		||||
modernc.org/sqlite v1.38.0 h1:+4OrfPQ8pxHKuWG4md1JpR/EYAh3Md7TdejuuzE7EUI=
 | 
			
		||||
modernc.org/sqlite v1.38.0/go.mod h1:1Bj+yES4SVvBZ4cBOpVZ6QgesMCKpJZDq0nxYzOpmNE=
 | 
			
		||||
							
								
								
									
										3
									
								
								src/httpsocket/go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/httpsocket/go.mod
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
module httpsocket
 | 
			
		||||
 | 
			
		||||
go 1.24.4
 | 
			
		||||
							
								
								
									
										20
									
								
								src/httpsocket/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/httpsocket/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	pid := os.Getpid()
 | 
			
		||||
	if err := os.WriteFile("/opt/packets/packets/http.pid", []byte(fmt.Sprint(pid)), 0644); err != nil {
 | 
			
		||||
		fmt.Println("error saving subprocess pid", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fs := http.FileServer(http.Dir("/var/cache/packets"))
 | 
			
		||||
	http.Handle("/", fs)
 | 
			
		||||
 | 
			
		||||
	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", 9123), nil))
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1048
									
								
								src/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1048
									
								
								src/main.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										3
									
								
								src/udpsocket/go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/udpsocket/go.mod
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
module udpsocket
 | 
			
		||||
 | 
			
		||||
go 1.24.4
 | 
			
		||||
							
								
								
									
										51
									
								
								src/udpsocket/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/udpsocket/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net"
 | 
			
		||||
	"os"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func CheckDownloaded(filename string) bool {
 | 
			
		||||
 | 
			
		||||
	_, err := os.Stat(fmt.Sprintf("/var/cache/packets/%s", filename))
 | 
			
		||||
	if os.IsNotExist(err) {
 | 
			
		||||
		return false
 | 
			
		||||
	} else {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	pid := os.Getpid()
 | 
			
		||||
	if err := os.WriteFile("/opt/packets/packets/udp.pid", []byte(fmt.Sprint(pid)), 0644); err != nil {
 | 
			
		||||
		fmt.Println("error saving subprocess pid", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	addr := net.UDPAddr{IP: net.IPv4zero, Port: 1333}
 | 
			
		||||
	conn, err := net.ListenUDP("udp", &addr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	defer conn.Close()
 | 
			
		||||
	buf := make([]byte, 1500)
 | 
			
		||||
 | 
			
		||||
	for {
 | 
			
		||||
		n, remote, err := conn.ReadFromUDP(buf)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Println("error creating udp socket", err)
 | 
			
		||||
		}
 | 
			
		||||
		msg := string(buf[:n])
 | 
			
		||||
		if !strings.HasPrefix(msg, "Q:") {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		filename := strings.TrimPrefix(msg, "Q:")
 | 
			
		||||
		if CheckDownloaded(filename) {
 | 
			
		||||
			reply := fmt.Sprintf("H:%s:%d", filename, 9123)
 | 
			
		||||
			conn.WriteToUDP([]byte(reply), remote)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user