@@ -1772,7 +1772,39 @@ func min500(batchIdx, total int) int {
17721772 return end - start
17731773}
17741774
1775- func writeSummary (results []configResult , failedLinks []string , duration float64 , originalTotal int ) {
1775+
1776+ package main
1777+
1778+ import (
1779+ "bufio"
1780+ "fmt"
1781+ "os"
1782+ "path/filepath"
1783+ "strings"
1784+ "time"
1785+ )
1786+
1787+ const batchSize = 500
1788+
1789+ type configResult struct {
1790+ proto string
1791+ }
1792+
1793+ var cfg struct {
1794+ ProtocolOrder []string
1795+ }
1796+
1797+ var gInputByProto = make (map [string ]int )
1798+
1799+ func countBatchFiles (path string ) int {
1800+ files , err := filepath .Glob (filepath .Join (path , "batch_*" ))
1801+ if err != nil {
1802+ return 0
1803+ }
1804+ return len (files )
1805+ }
1806+
1807+ func writeSummaryMinimal (results []configResult , failedLinks []string , duration float64 , originalTotal int ) {
17761808 byProtoOut := make (map [string ]int )
17771809 for _ , r := range results {
17781810 byProtoOut [r .proto ]++
@@ -1787,15 +1819,11 @@ func writeSummary(results []configResult, failedLinks []string, duration float64
17871819 defer w .Flush ()
17881820
17891821 repoBase := "https://github.com/Delta-Kronecker/V2ray-Config/raw/refs/heads/main"
1790- now := time .Now ().UTC ()
1791-
1792- fmt .Fprintf (w , "> Last updated: %s\n \n " , now .Format ("2006-01-02 15:04 UTC" ))
1793-
17941822
17951823 w .WriteString ("## Statistics\n \n " )
17961824
17971825 w .WriteString ("### Per-Protocol Input & Output\n \n " )
1798- fmt .Fprintf (w , "| Protocol | Tested (unique) | valid | Pass Rate |\n |---|---|---|---|\n " )
1826+ fmt .Fprintf (w , "| Protocol | Input (unique) | Output ( valid) | Pass Rate |\n |---|---|---|---|\n " )
17991827 totalIn := 0
18001828 totalOut := 0
18011829 for _ , p := range cfg .ProtocolOrder {
@@ -1822,6 +1850,7 @@ func writeSummary(results []configResult, failedLinks []string, duration float64
18221850 fmt .Fprintf (w , "| Processing time | %.2fs |\n \n " , duration )
18231851
18241852 w .WriteString ("---\n \n " )
1853+
18251854 w .WriteString ("## Main Files\n \n " )
18261855
18271856 w .WriteString ("### V2ray — All Configs\n \n " )
@@ -1850,24 +1879,21 @@ func writeSummary(results []configResult, failedLinks []string, duration float64
18501879 }
18511880 w .WriteString ("\n " )
18521881
1853- w .WriteString ("" )
1854-
1855- }
1856- }
1857- w .WriteString ("\n " )
1858-
18591882 w .WriteString ("---\n \n " )
1883+
18601884 w .WriteString ("## Batch Files — Random 500-Config Groups\n \n " )
18611885 w .WriteString ("> Each file contains 500 randomly selected configs from all protocols.\n \n " )
18621886
18631887 v2rayBatches := countBatchFiles ("config/batches/v2ray" )
18641888 clashBatches := countBatchFiles ("config/batches/clash" )
1865- clashAdvBatches := countBatchFiles ("config/batches/clash_advanced" )
18661889
18671890 w .WriteString ("### V2ray Batches\n \n " )
18681891 fmt .Fprintf (w , "| Batch | Count | Link |\n |---|---|---|\n " )
18691892 for i := 1 ; i <= v2rayBatches ; i ++ {
1870- cnt := min500 (i , len (results ))
1893+ cnt := batchSize
1894+ if i * batchSize > len (results ) {
1895+ cnt = len (results ) - (i - 1 )* batchSize
1896+ }
18711897 fmt .Fprintf (w , "| Batch %03d | %d | [batch_%03d.txt](%s/config/batches/v2ray/batch_%03d.txt) |\n " ,
18721898 i , cnt , i , repoBase , i )
18731899 }
@@ -1880,28 +1906,8 @@ func writeSummary(results []configResult, failedLinks []string, duration float64
18801906 i , i , repoBase , i )
18811907 }
18821908 w .WriteString ("\n " )
1883-
1884- w .WriteString ("" )
1885-
1886- }
1887- w .WriteString ("\n " )
1888-
1889-
1890-
1891- if len (failedLinks ) > 1000 {
1892- w .WriteString ("---\n \n " )
1893- w .WriteString ("## Failed Sources\n \n " )
1894- for _ , l := range failedLinks {
1895- fmt .Fprintf (w , "- %s\n " , l )
1896- }
1897- w .WriteString ("\n " )
1898- }
1899-
1900- w .WriteString ("---\n \n " )
1901- w .WriteString ("*Auto-generated by GitHub Actions.*\n " )
19021909}
19031910
1904-
19051911func decodeBase64 (encoded []byte ) (string , error ) {
19061912 s := strings .TrimSpace (strings .ReplaceAll (strings .ReplaceAll (string (encoded ), "\n " , "" ), "\r " , "" ))
19071913 if r := len (s ) % 4 ; r != 0 {
0 commit comments