mirror of
https://github.com/anotherhadi/iknowyou.git
synced 2026-04-12 00:47:26 +02:00
add proxy settings
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/config"
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/anotherhadi/iknowyou/internal/tools"
|
||||
)
|
||||
|
||||
@@ -66,6 +67,24 @@ func (m *Manager) Start(
|
||||
|
||||
ctx, cancel := context.WithCancel(parentCtx)
|
||||
|
||||
// Inject proxy-aware HTTP client into context.
|
||||
if httpClient, err := proxy.NewClient(cfg.Proxies); err != nil {
|
||||
cancel()
|
||||
return nil, fmt.Errorf("manager: building proxy client: %w", err)
|
||||
} else if httpClient != nil {
|
||||
ctx = proxy.WithClient(ctx, httpClient)
|
||||
}
|
||||
|
||||
// Generate proxychains config for external binary tools.
|
||||
var proxychainsCleanup func()
|
||||
if confPath, cleanup, err := proxy.WriteProxychainsConf(cfg.Proxies); err != nil {
|
||||
cancel()
|
||||
return nil, fmt.Errorf("manager: writing proxychains config: %w", err)
|
||||
} else if confPath != "" {
|
||||
ctx = proxy.WithProxychainsConf(ctx, confPath)
|
||||
proxychainsCleanup = cleanup
|
||||
}
|
||||
|
||||
s := &Search{
|
||||
ID: uuid.NewString(),
|
||||
Target: target,
|
||||
@@ -81,7 +100,7 @@ func (m *Manager) Start(
|
||||
m.searches[s.ID] = s
|
||||
m.mu.Unlock()
|
||||
|
||||
go m.runAll(ctx, s, activeTools)
|
||||
go m.runAll(ctx, s, activeTools, proxychainsCleanup)
|
||||
|
||||
return s, nil
|
||||
}
|
||||
@@ -208,7 +227,10 @@ func (m *Manager) instantiate(cfg *config.Config, inputType tools.InputType, pro
|
||||
return runners, statuses, nil
|
||||
}
|
||||
|
||||
func (m *Manager) runAll(ctx context.Context, s *Search, runners []tools.ToolRunner) {
|
||||
func (m *Manager) runAll(ctx context.Context, s *Search, runners []tools.ToolRunner, cleanup func()) {
|
||||
if cleanup != nil {
|
||||
defer cleanup()
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
for _, tool := range runners {
|
||||
wg.Add(1)
|
||||
|
||||
Reference in New Issue
Block a user