Skip to content

Commit 2376097

Browse files
authored
Merge pull request #9 from lordixir/main
v2.4.0: fix critical bugs, optimize cache, clean dead code
2 parents fddb570 + 69cdb90 commit 2376097

26 files changed

+1696
-235
lines changed

CHANGELOG.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,70 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [2.4.0] - 2026-02-22
6+
7+
### Added
8+
- **Go Embed Version**: VERSION file embedded at compile time via `go:embed`
9+
- **Domain Validation**: `-d` flag now validates domain format before processing
10+
- **Backward-Compatible JSON**: `found_websites` + `founded_websites` dual output
11+
- **Config File Support**: `-config config.yaml` flag for YAML configuration
12+
- **Resume Support**: `-resume cache.json` flag to resume interrupted scans
13+
- **Output Directory**: `-output-dir ./exports` flag for export file location
14+
15+
### Fixed
16+
- **Race Condition**: `PrintResult` protected with `sync.Once` (prevents double-call)
17+
- **DNS Key Mismatch**: Protocol prefix stripped before DNS result lookup
18+
- **CLI Flag Override**: `flag.Visit` ensures only explicitly set flags override config
19+
- **Windows Path Separator**: `filepath.Join` replaces hardcoded `/`
20+
- **Flaky DNS Test**: `minExpected` set to 0 for network-dependent test
21+
- **Chrome 131 Comment**: Updated stale comment to Chrome 135
22+
23+
### Improved
24+
- **Cache Performance**: `IsScanned()` O(n) → O(1) with persistent `map[string]struct{}`
25+
- **JSON Field Name**: `founded_websites``found_websites` (grammar fix)
26+
27+
### Removed
28+
- Unused `GetTransport()` method (conflicting transport settings)
29+
- Unused `AddSmartJitter()`, `SaveConfigFile()`, `ParseDNSServers()` functions
30+
- Unused `BatchReverseDNSWithResults()` function and `DNSResult` struct
31+
- Unused `PoolMetrics` struct and related atomic operations
32+
33+
---
34+
35+
## [2.3.0] - 2025-12-23
36+
37+
### Added
38+
- **Batch DNS Lookup**: Parallel DNS resolution at end of scan (20 concurrent queries)
39+
- **Connection Pool Optimization**: Pre-warming, larger buffers, TLS session cache
40+
41+
### Changed
42+
- **Chrome 135 User-Agent**: Updated from Chrome 131 to Chrome 135 for January 2026
43+
- **macOS 15 Sequoia**: Added new macOS version strings
44+
- **Windows 11 24H2**: Updated Windows version strings
45+
- Increased connection pool sizes: MaxIdle 200-1000, MaxPerHost 50-200
46+
- Extended idle timeout: 60s → 90s
47+
- Larger I/O buffers: 64KB read/write
48+
49+
### Fixed
50+
- Batch DNS now correctly extracts IP from URL (removes https:// prefix)
51+
52+
---
53+
54+
## [2.2.2] - 2025-12-12
55+
56+
### Fixed
57+
- **uTLS Transport Activated**: Chrome 131 TLS fingerprint now fully integrated into HTTP client
58+
- Fixed HTTP/2 compatibility issue by setting `ForceAttemptHTTP2: false`
59+
- uTLS transport now properly used for all HTTPS connections
60+
61+
---
62+
563
## [2.2.1] - 2025-12-11
664

765
### Added
866
- **Referer Header Rotation**: Random referer from Google, Bing, DuckDuckGo for more realistic requests
9-
- **Smart Jitter Function**: `config.AddSmartJitter()` with occasional long pauses (1-3s) for natural patterns
10-
- **uTLS Transport**: Chrome 131 TLS fingerprint support (ready for integration)
67+
- **Smart Jitter Function**: `config.AddSmartJitter()` *(removed in v2.4.0)*
68+
- **uTLS Transport**: Chrome 131 TLS fingerprint support
1169
- New config constants: `DialTimeout`, `MaxJitterMs`
1270
- Unified RNG functions in config: `GetRandomInt`, `GetRandomString`, `ShuffleStrings`
1371

CONTRIBUTING.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,28 @@ go vet ./...
5656

5757
```
5858
ipmap/
59-
├── main.go # Entry point, CLI flags
59+
├── main.go # Entry point, CLI flags, go:embed VERSION
60+
├── VERSION # Embedded version string
6061
├── config/
61-
│ └── config.go # Global config, RNG, jitter functions
62+
│ ├── config.go # Global config, RNG, jitter, logging
63+
│ └── loader.go # YAML config file loading
6264
├── modules/
63-
│ ├── scanner.go # Chrome 131 headers, uTLS transport
64-
│ ├── request.go # HTTP client with retry
65-
│ ├── resolve_site.go # Worker pool, IP scanning
65+
│ ├── scanner.go # Chrome 135 headers, uTLS transport
66+
│ ├── request.go # HTTP client with retry, connection pool
67+
│ ├── resolve_site.go # Worker pool, IP scanning, batch DNS
6668
│ ├── get_site.go # Site discovery per IP
69+
│ ├── get_domain_title.go # Domain title fetching
70+
│ ├── helpers.go # Shared utilities (ExtractTitle)
71+
│ ├── cache.go # Scan state persistence for resume
6772
│ ├── validators.go # Input validation
6873
│ ├── rate_limiter.go # Token bucket rate limiter
69-
│ └── ...
74+
│ ├── dns_resolver.go # Batch reverse DNS lookups
75+
│ ├── result_print.go # Result formatting and export
76+
│ ├── interrupt_handler.go # Ctrl+C handling
77+
│ └── calc_ip_address.go # CIDR to IP calculation
7078
├── tools/
7179
│ ├── find_asn.go # ASN scanning
7280
│ └── find_ip.go # IP block scanning
73-
├── bin/ # Cross-platform builds
7481
└── README.md
7582
```
7683

@@ -113,10 +120,10 @@ When modifying the scanner module:
113120

114121
1. **TLS Fingerprint**: Use `utls.HelloChrome_Auto` for latest Chrome fingerprint
115122
2. **Header Order**: Maintain exact Chrome header order (not alphabetical)
116-
3. **Accept-Encoding**: Include `zstd` for Chrome 131+
117-
4. **Jitter**: Use `config.AddJitter()` (0-200ms) or `config.AddSmartJitter()` (with occasional long pauses)
118-
5. **User-Agent**: Use Chrome 130+ versions only
119-
6. **Referer**: Rotate between Google, Bing, DuckDuckGo URLs
123+
3. **Accept-Encoding**: Include `zstd` for Chrome 135+
124+
4. **Jitter**: Use `config.AddJitter()` (0-200ms random delay)
125+
5. **User-Agent**: Use Chrome 133+ versions only
126+
6. **Referer**: Rotate between Google, Bing, DuckDuckGo, Yahoo URLs
120127

121128
## License
122129

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ An open-source, cross-platform powerful network analysis tool for discovering we
77
- ASN scanning (Autonomous System Number) with IPv4/IPv6 support
88
- IP block scanning (CIDR format)
99
- HTTPS/HTTP automatic fallback
10-
- **Chrome 131 TLS Fingerprint** (JA3/JA4 spoofing via uTLS)
10+
- **Chrome 135 TLS Fingerprint** (JA3/JA4 spoofing via uTLS)
1111
- **Real Chrome Header Order** (WAF bypass optimized)
1212
- **Referer Header Rotation** (Google, Bing, DuckDuckGo)
1313
- Firewall bypass techniques (IP shuffling, header randomization, smart jitter)
@@ -57,6 +57,11 @@ go build -o ipmap .
5757
-proxy http://127.0.0.1:8080 # Proxy URL (HTTP/HTTPS/SOCKS5)
5858
-rate 50 # Rate limit (requests/sec, 0 = unlimited)
5959
-dns 8.8.8.8,1.1.1.1 # Custom DNS servers
60+
-ipv6 # Enable IPv6 scanning
61+
-config config.yaml # Load config from YAML file
62+
-resume cache.json # Resume interrupted scan from cache
63+
-output-dir ./exports # Directory for export files
64+
-insecure=false # Enable TLS certificate verification
6065
```
6166

6267
### Examples

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.1
1+
2.4.0

build.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ipmap Multi-Platform Build Script
22
# Builds for macOS (ARM64 + AMD64) and Linux (AMD64)
33

4-
$VERSION = "2.2.1"
4+
$VERSION = "2.2.2"
55
$APP_NAME = "ipmap"
66
$BUILD_DIR = "bin"
77

@@ -52,6 +52,19 @@ if ($LASTEXITCODE -eq 0) {
5252
}
5353
Write-Host ""
5454

55+
# Build for Windows AMD64
56+
Write-Host "Building for Windows AMD64..." -ForegroundColor Yellow
57+
$env:GOOS = "windows"
58+
$env:GOARCH = "amd64"
59+
go build -o "$BUILD_DIR/${APP_NAME}_windows_amd64.exe" .
60+
if ($LASTEXITCODE -eq 0) {
61+
Write-Host "SUCCESS: Windows AMD64 build completed" -ForegroundColor Green
62+
} else {
63+
Write-Host "ERROR: Windows AMD64 build failed" -ForegroundColor Red
64+
exit 1
65+
}
66+
Write-Host ""
67+
5568
# Show file sizes
5669
Write-Host "Build Summary:" -ForegroundColor Cyan
5770
Write-Host "================================================" -ForegroundColor Gray

config/config.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var (
4242
Format string
4343

4444
// MaxRetries is the number of retry attempts for failed requests
45-
MaxRetries int = 2
45+
MaxRetries int = 0
4646

4747
// Workers is the number of concurrent scanning goroutines
4848
Workers int = 100
@@ -55,6 +55,15 @@ var (
5555

5656
// DNSServers is the list of custom DNS servers
5757
DNSServers []string
58+
59+
// EnableIPv6 enables IPv6 address scanning (default: false)
60+
EnableIPv6 bool = false
61+
62+
// OutputDir is the directory for export files (default: current directory)
63+
OutputDir string = ""
64+
65+
// InsecureSkipVerify skips TLS certificate verification (default: true for backward compatibility)
66+
InsecureSkipVerify bool = true
5867
)
5968

6069
// ====================================================================
@@ -104,19 +113,6 @@ func AddJitter() {
104113
}
105114
}
106115

107-
// AddSmartJitter adds intelligent jitter with occasional long pauses for more natural patterns
108-
// This helps bypass rate-based WAF detection
109-
func AddSmartJitter() {
110-
base := 50 + GetRandomInt(150) // 50-200ms base
111-
112-
// 5% chance of a long pause (simulates user reading page)
113-
if GetRandomInt(100) < 5 {
114-
base += 1000 + GetRandomInt(2000) // +1-3 seconds
115-
}
116-
117-
time.Sleep(time.Duration(base) * time.Millisecond)
118-
}
119-
120116
// ====================================================================
121117
// LOGGING FUNCTIONS
122118
// ====================================================================

config/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ func TestInfoLog(t *testing.T) {
9898
}
9999

100100
func TestConfigDefaults(t *testing.T) {
101-
if MaxRetries != 2 {
102-
t.Errorf("MaxRetries default should be 2, got %d", MaxRetries)
101+
if MaxRetries != 0 {
102+
t.Errorf("MaxRetries default should be 0 (retries disabled), got %d", MaxRetries)
103103
}
104104
if Workers != 100 {
105105
t.Errorf("Workers default should be 100, got %d", Workers)

config/loader.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Package config provides global configuration for the ipmap scanner.
2+
// loader.go handles configuration file loading and parsing.
3+
package config
4+
5+
import (
6+
"os"
7+
8+
"gopkg.in/yaml.v3"
9+
)
10+
11+
// FileConfig represents the structure of the config.yaml file
12+
type FileConfig struct {
13+
Workers int `yaml:"workers"`
14+
Timeout int `yaml:"timeout"`
15+
RateLimit int `yaml:"rate_limit"`
16+
Proxy string `yaml:"proxy"`
17+
DNSServers []string `yaml:"dns_servers"`
18+
IPv6 bool `yaml:"ipv6"`
19+
Verbose bool `yaml:"verbose"`
20+
Format string `yaml:"format"`
21+
}
22+
23+
// LoadConfigFile loads configuration from a YAML file
24+
// Returns nil if file doesn't exist or is invalid
25+
func LoadConfigFile(path string) (*FileConfig, error) {
26+
data, err := os.ReadFile(path)
27+
if err != nil {
28+
return nil, err
29+
}
30+
31+
var cfg FileConfig
32+
if err := yaml.Unmarshal(data, &cfg); err != nil {
33+
return nil, err
34+
}
35+
36+
return &cfg, nil
37+
}
38+
39+
// ApplyFileConfig applies file configuration to global config
40+
// Only applies non-zero/non-empty values (allows CLI to override)
41+
func ApplyFileConfig(cfg *FileConfig) {
42+
if cfg == nil {
43+
return
44+
}
45+
46+
if cfg.Workers > 0 {
47+
Workers = cfg.Workers
48+
}
49+
if cfg.RateLimit > 0 {
50+
RateLimit = cfg.RateLimit
51+
}
52+
if cfg.Proxy != "" {
53+
ProxyURL = cfg.Proxy
54+
}
55+
if len(cfg.DNSServers) > 0 {
56+
DNSServers = cfg.DNSServers
57+
}
58+
if cfg.IPv6 {
59+
EnableIPv6 = cfg.IPv6
60+
}
61+
if cfg.Verbose {
62+
Verbose = cfg.Verbose
63+
}
64+
if cfg.Format != "" {
65+
Format = cfg.Format
66+
}
67+
}
68+
69+
// FindConfigFile looks for config file in common locations
70+
func FindConfigFile() string {
71+
// Check common locations in order
72+
locations := []string{
73+
"config.yaml",
74+
"config.yml",
75+
".ipmap.yaml",
76+
".ipmap.yml",
77+
}
78+
79+
// Also check in user home directory
80+
if home, err := os.UserHomeDir(); err == nil {
81+
locations = append(locations, home+"/.ipmap.yaml", home+"/.ipmap.yml")
82+
}
83+
84+
for _, loc := range locations {
85+
if _, err := os.Stat(loc); err == nil {
86+
return loc
87+
}
88+
}
89+
90+
return ""
91+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/refraction-networking/utls v1.8.1
77
github.com/schollz/progressbar/v3 v3.14.1
88
golang.org/x/net v0.48.0
9+
gopkg.in/yaml.v3 v3.0.1
910
)
1011

1112
require (
@@ -17,5 +18,4 @@ require (
1718
golang.org/x/crypto v0.46.0 // indirect
1819
golang.org/x/sys v0.39.0 // indirect
1920
golang.org/x/term v0.38.0 // indirect
20-
golang.org/x/text v0.32.0 // indirect
2121
)

go.sum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
3232
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
3333
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
3434
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
35-
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
36-
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
35+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3736
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
38-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
3937
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
38+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
39+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)