|
62 | 62 | insecure bool |
63 | 63 | confirmBurn bool |
64 | 64 | skipTLSVerify bool |
| 65 | + proxy string |
65 | 66 |
|
66 | 67 | rootCmd = &cobra.Command{ |
67 | 68 | Use: "privatebin", |
@@ -136,6 +137,23 @@ var ( |
136 | 137 | ) |
137 | 138 | } |
138 | 139 |
|
| 140 | + proxyAddr := binCfg.Proxy |
| 141 | + if proxy != "" { |
| 142 | + proxyAddr = proxy |
| 143 | + } |
| 144 | + |
| 145 | + if proxyAddr != "" { |
| 146 | + proxyURL, err := url.Parse(proxyAddr) |
| 147 | + if err != nil { |
| 148 | + return fmt.Errorf("cannot parse proxy url %q: %w", proxyAddr, err) |
| 149 | + } |
| 150 | + |
| 151 | + clientOptions = append( |
| 152 | + clientOptions, |
| 153 | + privatebin.WithProxyURL(*proxyURL), |
| 154 | + ) |
| 155 | + } |
| 156 | + |
139 | 157 | host, err := url.Parse(binCfg.Host) |
140 | 158 | if err != nil { |
141 | 159 | return fmt.Errorf("cannot parse %q bin %q host: %w", binCfg.Name, binCfg.Host, err) |
@@ -306,6 +324,7 @@ func init() { |
306 | 324 | rootCmd.PersistentFlags().StringVarP(&cfgPath, "config", "c", "", "the config file (default is $HOME/.config/privatebin/config.json)") |
307 | 325 | rootCmd.PersistentFlags().StringVarP(&binName, "bin", "b", "", "the name of the privatebin instance to use (default \"\")") |
308 | 326 | rootCmd.PersistentFlags().StringSliceVarP(&extraHeaderFields, "header", "H", []string{}, "extra HTTP header fields to include in the request sent") |
| 327 | + rootCmd.PersistentFlags().StringVar(&proxy, "proxy", "", "proxy URL to use for requests (e.g. socks5://127.0.0.1:9050 for TOR)") |
309 | 328 |
|
310 | 329 | createCmd.Flags().StringVar(&expire, "expire", "", "the time to live of the paste") |
311 | 330 | createCmd.Flags().BoolVar(&openDiscussion, "open-discussion", false, "enable discussion on the paste") |
|
0 commit comments