How to use Port method of html Package

Best K6 code snippet using html.Port

flags.go

Source:flags.go Github

copy

Full Screen

...39 ReportSubdomainDB bool40 ReportCommon bool41 ReportRedirect bool42 ReportVirusTotal bool43 ReportTimeoutPort int44 DNSTarget string45 DNSOutputJson string46 DNSOutputHtml string47 DNSOutputTxt string48 DNSPlain bool49 SubdomainTarget string50 SubdomainWord string51 SubdomainOutputJson string52 SubdomainOutputHtml string53 SubdomainOutputTxt string54 SubdomainIgnore []string55 SubdomainCrawler bool56 SubdomainDB bool57 SubdomainPlain bool58 SubdomainNoCheck bool59 SubdomainVirusTotal bool60 DirTarget string61 DirWord string62 DirOutputJson string63 DirOutputHtml string64 DirOutputTxt string65 DirIgnore []string66 DirCrawler bool67 DirPlain bool68 DirRedirect bool69 PortTarget string70 PortOutputJson string71 PortOutputHtml string72 PortOutputTxt string73 StartPort int74 EndPort int75 PortArrayBool bool76 PortsArray []int77 PortCommon bool78 PortPlain bool79 PortTimeout int80}81//ReadArgs reads arguments/options from stdin82// Subcommands:83// report ==> Full report84// dns ==> Dns records enumeration85// subdomains ==> Subdomains enumeration86// port ==> ports enumeration87// dir ==> directiories enumeration88// help ==> doc89// examples ==> examples90func ReadArgs() Input {91 reportCommand := flag.NewFlagSet("report", flag.ExitOnError)92 dnsCommand := flag.NewFlagSet("dns", flag.ExitOnError)93 subdomainCommand := flag.NewFlagSet("subdomain", flag.ExitOnError)94 portCommand := flag.NewFlagSet("port", flag.ExitOnError)95 dirCommand := flag.NewFlagSet("dir", flag.ExitOnError)96 helpCommand := flag.NewFlagSet("help", flag.ExitOnError)97 examplesCommand := flag.NewFlagSet("examples", flag.ExitOnError)98 // report subcommand flag pointers99 reportTargetPtr := reportCommand.String("target", "", "Target {URL/IP} (Required)")100 // report subcommand flag pointers101 reportPortsPtr := reportCommand.String("p", "", "ports range <start-end>")102 // report subcommand flag pointers103 reportWordlistDirPtr := reportCommand.String("wd", "", "wordlist to use for directories (default enabled)")104 // report subcommand flag pointers105 reportWordlistSubdomainPtr := reportCommand.String("ws", "", "wordlist to use for subdomains (default enabled)")106 // report subcommand flag pointers107 reportOutputJsonPtr := reportCommand.String("oj", "", "JSON output path where save the results to")108 // report subcommand flag pointers109 reportOutputHtmlPtr := reportCommand.String("oh", "", "HTML output path where save the results to")110 // report subcommand flag pointers111 reportOutputTxtPtr := reportCommand.String("ot", "", "TXT output path where save the results to")112 // report subcommand flag pointers113 reportIgnoreDirPtr := reportCommand.String("id", "", "Ignore response code(s) for directories scanning")114 reportIgnoreDir := []string{}115 // report subcommand flag pointers116 reportIgnoreSubPtr := reportCommand.String("is", "", "Ignore response code(s) for subdomains scanning")117 reportIgnoreSub := []string{}118 // report subcommand flag pointers119 reportCrawlerDirPtr := reportCommand.Bool("cd", false, "Use also a web crawler for directories enumeration")120 // report subcommand flag pointers121 reportCrawlerSubdomainPtr := reportCommand.Bool("cs", false, "Use also a web crawler for subdomains enumeration")122 // report subcommand flag pointers123 reportSubdomainDBPtr := reportCommand.Bool("db", false, "Use also a public database for subdomains enumeration")124 // report subcommand flag pointers125 reportCommonPtr := reportCommand.Bool("common", false, "Scan common ports")126 // report subcommand flag pointers127 reportRedirectPtr := reportCommand.Bool("nr", false, "No follow redirects")128 // report subcommand flag pointers129 reportVirusTotalPtr := reportCommand.Bool("vt", false, "Use VirusTotal as a subdomain source")130 // report subcommand flag pointers131 reportTimeoutPortPtr := reportCommand.Int("tp", 3, "Scan Port timeout")132 // dns subcommand flag pointers133 dnsTargetPtr := dnsCommand.String("target", "", "Target {URL/IP} (Required)")134 // dns subcommand flag pointers135 dnsOutputJsonPtr := dnsCommand.String("oj", "", "JSON output path where save the results to")136 // dns subcommand flag pointers137 dnsOutputHtmlPtr := dnsCommand.String("oh", "", "HTML output path where save the results to")138 // dns subcommand flag pointers139 dnsOutputTxtPtr := dnsCommand.String("ot", "", "TXT output path where save the results to")140 // dns subcommand flag pointers141 dnsPlainPtr := dnsCommand.Bool("plain", false, "Print only results")142 // subdomains subcommand flag pointers143 subdomainTargetPtr := subdomainCommand.String("target", "", "Target {URL} (Required)")144 // subdomains subcommand wordlist145 subdomainWordlistPtr := subdomainCommand.String("w", "", "wordlist to use (default enabled)")146 // subdomains subcommand flag pointers147 subdomainOutputJsonPtr := subdomainCommand.String("oj", "", "JSON output path where save the results to")148 // subdomains subcommand flag pointers149 subdomainOutputHtmlPtr := subdomainCommand.String("oh", "", "HTML output path where save the results to")150 // subdomains subcommand flag pointers151 subdomainOutputTxtPtr := subdomainCommand.String("ot", "", "TXT output path where save the results to")152 // subdomains subcommand flag pointers153 subdomainIgnorePtr := subdomainCommand.String("i", "", "Ignore response code(s)")154 subdomainIgnore := []string{}155 // subdomains subcommand flag pointers156 subdomainCrawlerPtr := subdomainCommand.Bool("c", false, "Use also a web crawler")157 // subdomains subcommand flag pointers158 subdomainDBPtr := subdomainCommand.Bool("db", false, "Use also public databases")159 // subdomains subcommand flag pointers160 subdomainPlainPtr := subdomainCommand.Bool("plain", false, "Print only results")161 // subdomains subcommand flag pointers162 subdomainNoCheckPtr := subdomainCommand.Bool("no-check", false, "Don't check status codes for subdomains.")163 // subdomains subcommand flag pointers164 subdomainVirusTotalPtr := subdomainCommand.Bool("vt", false, "Use VirusTotal as a subdomain source")165 // dir subcommand flag pointers166 dirTargetPtr := dirCommand.String("target", "", "Target {URL/IP} (Required)")167 // dir subcommand wordlist168 dirWordlistPtr := dirCommand.String("w", "", "wordlist to use (default enabled)")169 // dir subcommand flag pointers170 dirOutputJsonPtr := dirCommand.String("oj", "", "JSON output path where save the results to")171 // dir subcommand flag pointers172 dirOutputHtmlPtr := dirCommand.String("oh", "", "HTML output path where save the results to")173 // dir subcommand flag pointers174 dirOutputTxtPtr := dirCommand.String("ot", "", "TXT output path where save the results to")175 // dir subcommand flag pointers176 dirIgnorePtr := dirCommand.String("i", "", "Ignore response code(s)")177 dirIgnore := []string{}178 // dir subcommand flag pointers179 dirCrawlerPtr := dirCommand.Bool("c", false, "Use also a web crawler")180 // dir subcommand flag pointers181 dirPlainPtr := dirCommand.Bool("plain", false, "Print only results")182 // dir subcommand flag pointers183 dirRedirectPtr := dirCommand.Bool("nr", false, "No follow redirects")184 // port subcommand flag pointers185 portTargetPtr := portCommand.String("target", "", "Target {URL/IP} (Required)")186 // port subcommand flag pointers187 portOutputJsonPtr := portCommand.String("oj", "", "JSON output path where save the results to")188 // port subcommand flag pointers189 portOutputHtmlPtr := portCommand.String("oh", "", "HTML output path where save the results to")190 // port subcommand flag pointers191 portOutputTxtPtr := portCommand.String("ot", "", "TXT output path where save the results to")192 // port subcommand flag pointers193 portsPtr := portCommand.String("p", "", "ports range <start-end>")194 // port subcommand flag pointers195 portCommonPtr := portCommand.Bool("common", false, "Scan common ports")196 // port subcommand flag pointers197 portPlainPtr := portCommand.Bool("plain", false, "Print only results")198 // port subcommand flag pointers199 portTimeoutPtr := portCommand.Int("t", 3, "Port scan timeout")200 // Default ports201 StartPort := 1202 EndPort := 65535203 portsArray := []int{}204 portArrayBool := false205 // Verify that a subcommand has been provided206 // os.Arg[0] is the main command207 // os.Arg[1] will be the subcommand208 if len(os.Args) < 2 {209 output.Intro()210 fmt.Println("[ERROR] subcommand is required.")211 fmt.Println(" Type: scilla help - Full overview of the commands.")212 fmt.Println(" Type: scilla examples - Some explanatory examples.")213 os.Exit(1)214 }215 // Switch on the subcommand216 // Parse the flags for appropriate FlagSet217 switch os.Args[1] {218 case "report":219 err := reportCommand.Parse(os.Args[2:])220 if err != nil {221 log.Fatal(err)222 }223 case "dns":224 err := dnsCommand.Parse(os.Args[2:])225 if err != nil {226 log.Fatal(err)227 }228 case "subdomain":229 err := subdomainCommand.Parse(os.Args[2:])230 if err != nil {231 log.Fatal(err)232 }233 case "port":234 err := portCommand.Parse(os.Args[2:])235 if err != nil {236 log.Fatal(err)237 }238 case "dir":239 err := dirCommand.Parse(os.Args[2:])240 if err != nil {241 log.Fatal(err)242 }243 case "help":244 output.Intro()245 err := helpCommand.Parse(os.Args[2:])246 if err != nil {247 log.Fatal(err)248 }249 case "examples":250 output.Intro()251 err := examplesCommand.Parse(os.Args[2:])252 if err != nil {253 log.Fatal(err)254 }255 default:256 output.Intro()257 output.Help()258 os.Exit(1)259 }260 // REPORT subcommand261 if reportCommand.Parsed() {262 if *reportOutputJsonPtr != "" {263 *reportOutputJsonPtr = output.AppendExtension(*reportOutputJsonPtr, "json")264 }265 if *reportOutputHtmlPtr != "" {266 *reportOutputHtmlPtr = output.AppendExtension(*reportOutputHtmlPtr, "html")267 }268 if *reportOutputTxtPtr != "" {269 *reportOutputTxtPtr = output.AppendExtension(*reportOutputTxtPtr, "txt")270 }271 StartPort, EndPort, portsArray, portArrayBool, reportIgnoreDir, reportIgnoreSub = ReportSubcommandCheckFlags(*reportCommand,272 reportTargetPtr, reportPortsPtr, reportCommonPtr,273 reportVirusTotalPtr, reportSubdomainDBPtr, StartPort,274 EndPort, reportIgnoreDirPtr, reportIgnoreSubPtr, reportTimeoutPortPtr,275 reportOutputJsonPtr, reportOutputHtmlPtr, reportOutputTxtPtr)276 }277 // DNS subcommand278 if dnsCommand.Parsed() {279 if *dnsOutputJsonPtr != "" {280 *dnsOutputJsonPtr = output.AppendExtension(*dnsOutputJsonPtr, "json")281 }282 if *dnsOutputHtmlPtr != "" {283 *dnsOutputHtmlPtr = output.AppendExtension(*dnsOutputHtmlPtr, "html")284 }285 if *dnsOutputTxtPtr != "" {286 *dnsOutputTxtPtr = output.AppendExtension(*dnsOutputTxtPtr, "txt")287 }288 DNSSubcommandCheckFlags(*dnsCommand, dnsTargetPtr, dnsOutputJsonPtr, dnsOutputHtmlPtr, dnsOutputTxtPtr)289 }290 // SUBDOMAIN subcommand291 if subdomainCommand.Parsed() {292 if *subdomainOutputJsonPtr != "" {293 *subdomainOutputJsonPtr = output.AppendExtension(*subdomainOutputJsonPtr, "json")294 }295 if *subdomainOutputHtmlPtr != "" {296 *subdomainOutputHtmlPtr = output.AppendExtension(*subdomainOutputHtmlPtr, "html")297 }298 if *subdomainOutputTxtPtr != "" {299 *subdomainOutputTxtPtr = output.AppendExtension(*subdomainOutputTxtPtr, "txt")300 }301 subdomainIgnore = SubdomainSubcommandCheckFlags(*subdomainCommand, subdomainTargetPtr,302 subdomainNoCheckPtr, subdomainDBPtr, subdomainWordlistPtr, subdomainIgnorePtr,303 subdomainCrawlerPtr, subdomainVirusTotalPtr,304 subdomainOutputJsonPtr, subdomainOutputHtmlPtr, subdomainOutputTxtPtr)305 }306 // PORT subcommand307 if portCommand.Parsed() {308 if *portOutputJsonPtr != "" {309 *portOutputJsonPtr = output.AppendExtension(*portOutputJsonPtr, "json")310 }311 if *portOutputHtmlPtr != "" {312 *portOutputHtmlPtr = output.AppendExtension(*portOutputHtmlPtr, "html")313 }314 if *portOutputTxtPtr != "" {315 *portOutputTxtPtr = output.AppendExtension(*portOutputTxtPtr, "txt")316 }317 StartPort, EndPort, portsArray, portArrayBool = PortSubcommandCheckFlags(*portCommand, portTargetPtr, portsPtr,318 portCommonPtr, StartPort, EndPort, portTimeoutPtr, portOutputJsonPtr, portOutputHtmlPtr, portOutputTxtPtr)319 }320 // DIR subcommand321 if dirCommand.Parsed() {322 if *dirOutputJsonPtr != "" {323 *dirOutputJsonPtr = output.AppendExtension(*dirOutputJsonPtr, "json")324 }325 if *dirOutputHtmlPtr != "" {326 *dirOutputHtmlPtr = output.AppendExtension(*dirOutputHtmlPtr, "html")327 }328 if *dirOutputTxtPtr != "" {329 *dirOutputTxtPtr = output.AppendExtension(*dirOutputTxtPtr, "txt")330 }331 dirIgnore = DirSubcommandCheckFlags(*dirCommand, dirTargetPtr, dirIgnorePtr,332 dirOutputJsonPtr, dirOutputHtmlPtr, dirOutputTxtPtr)333 }334 // HELP subcommand335 if helpCommand.Parsed() {336 // Print help337 output.Help()338 os.Exit(0)339 }340 // EXAMPLES subcommand341 if examplesCommand.Parsed() {342 // Print examples343 output.Examples()344 os.Exit(0)345 }346 result := Input{347 *reportTargetPtr,348 *reportWordlistDirPtr,349 *reportWordlistSubdomainPtr,350 *reportOutputJsonPtr,351 *reportOutputHtmlPtr,352 *reportOutputTxtPtr,353 reportIgnoreDir,354 reportIgnoreSub,355 *reportCrawlerDirPtr,356 *reportCrawlerSubdomainPtr,357 *reportSubdomainDBPtr,358 *reportCommonPtr,359 *reportRedirectPtr,360 *reportVirusTotalPtr,361 *reportTimeoutPortPtr,362 *dnsTargetPtr,363 *dnsOutputJsonPtr,364 *dnsOutputHtmlPtr,365 *dnsOutputTxtPtr,366 *dnsPlainPtr,367 *subdomainTargetPtr,368 *subdomainWordlistPtr,369 *subdomainOutputJsonPtr,370 *subdomainOutputHtmlPtr,371 *subdomainOutputTxtPtr,372 subdomainIgnore,373 *subdomainCrawlerPtr,374 *subdomainDBPtr,375 *subdomainPlainPtr,376 *subdomainNoCheckPtr,377 *subdomainVirusTotalPtr,378 *dirTargetPtr,379 *dirWordlistPtr,380 *dirOutputJsonPtr,381 *dirOutputHtmlPtr,382 *dirOutputTxtPtr,383 dirIgnore,384 *dirCrawlerPtr,385 *dirPlainPtr,386 *dirRedirectPtr,387 *portTargetPtr,388 *portOutputJsonPtr,389 *portOutputHtmlPtr,390 *portOutputTxtPtr,391 StartPort,392 EndPort,393 portArrayBool,394 portsArray,395 *portCommonPtr,396 *portPlainPtr,397 *portTimeoutPtr,398 }399 return result400}...

Full Screen

Full Screen

httprequest.go

Source:httprequest.go Github

copy

Full Screen

...37// Note the returned host is not normalized, and may or may not contain a port.38// Returned values are based on the following information:39//40// Host:41// * X-Forwarded-Host/X-Forwarded-Port headers42// * Host field on the request (parsed from Host header)43// * Host in the request's URL (parsed from Request-Line)44//45// Scheme:46// * X-Forwarded-Proto header47// * Existence of TLS information on the request implies https48// * Scheme in the request's URL (parsed from Request-Line)49// * Port (if included in calculated Host value, 443 implies https)50// * Otherwise, defaults to "http"51func SchemeHost(req *http.Request) (string /*scheme*/, string /*host*/) {52 forwarded := func(attr string) string {53 // Get the X-Forwarded-<attr> value54 value := req.Header.Get("X-Forwarded-" + attr)55 // Take the first comma-separated value, if multiple exist56 value = strings.SplitN(value, ",", 2)[0]57 // Trim whitespace58 return strings.TrimSpace(value)59 }60 hasExplicitHost := func(h string) bool {61 _, _, err := net.SplitHostPort(h)62 return err == nil63 }64 forwardedHost := forwarded("Host")65 host := ""66 hostHadExplicitPort := false67 switch {68 case len(forwardedHost) > 0:69 host = forwardedHost70 hostHadExplicitPort = hasExplicitHost(host)71 // If both X-Forwarded-Host and X-Forwarded-Port are sent, use the explicit port info72 if forwardedPort := forwarded("Port"); len(forwardedPort) > 0 {73 if h, _, err := net.SplitHostPort(forwardedHost); err == nil {74 host = net.JoinHostPort(h, forwardedPort)75 } else {76 host = net.JoinHostPort(forwardedHost, forwardedPort)77 }78 }79 case len(req.Host) > 0:80 host = req.Host81 hostHadExplicitPort = hasExplicitHost(host)82 case len(req.URL.Host) > 0:83 host = req.URL.Host84 hostHadExplicitPort = hasExplicitHost(host)85 }86 port := ""87 if _, p, err := net.SplitHostPort(host); err == nil {88 port = p89 }90 forwardedProto := forwarded("Proto")91 scheme := ""92 switch {93 case len(forwardedProto) > 0:94 scheme = forwardedProto95 case req.TLS != nil:96 scheme = "https"97 case len(req.URL.Scheme) > 0:98 scheme = req.URL.Scheme99 case port == "443":100 scheme = "https"101 default:102 scheme = "http"103 }104 if !hostHadExplicitPort {105 if (scheme == "https" && port == "443") || (scheme == "http" && port == "80") {106 if hostWithoutPort, _, err := net.SplitHostPort(host); err == nil {107 host = hostWithoutPort108 }109 }110 }111 return scheme, host112}...

Full Screen

Full Screen

cli.go

Source:cli.go Github

copy

Full Screen

1package cli2import (3 "flag"4 "fmt"5 "os"6 "github.com/paolochang/gocoin/explorer"7 "github.com/paolochang/gocoin/rest"8)9func usage() {10 fmt.Printf("Welcome to Go Coin\n\n")11 fmt.Printf("Please use the following flags:\n\n")12 fmt.Printf("-mode: Select the mode from 'all', 'rest', or 'html' (default 'all')\n")13 fmt.Printf("-port: Start the PORT of the server (default 4000)\n\n")14 os.Exit(0)15}16func Strat() {17 mode := flag.String("mode", "all", "Select the mode from 'html', 'rest', or 'all'")18 port := flag.Int("port", 4000, "Set port of the server")19 flag.Parse()20 switch *mode {21 case "rest":22 fmt.Println("Start REST API server")23 rest.Start(*port)24 case "html":25 fmt.Println("Start HTML server")26 explorer.Start(*port)27 case "all":28 fmt.Println("Start REST API and HTML server\nTo see the CLI command usage, run: go run main.go -mode=help")29 go explorer.Start(*port)30 rest.Start(*port+1)31 case "help":32 usage()33 }}...

Full Screen

Full Screen

Port

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 http.HandleFunc("/", index)4 http.HandleFunc("/about", about)5 fmt.Println("Server is running on port", port)6 http.ListenAndServe(port, nil)7}8func index(w http.ResponseWriter, r *http.Request) {9 fmt.Fprintln(w, "Welcome to my website")10}11func about(w http.ResponseWriter, r *http.Request) {12 fmt.Fprintln(w, "This is my about page")13}

Full Screen

Full Screen

Port

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.Port("http", "www.example.com", 80))4 fmt.Println(html.Port("https", "www.example.com", 443))5 fmt.Println(html.Port("ftp", "ftp.example.com", 21))6}

Full Screen

Full Screen

Port

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Port:", http.Port(":8080"))4 fmt.Println("Port:", http.Port("8080"))5 fmt.Println("Port:", http.Port("localhost:8080"))6 fmt.Println("Port:", http.Port("localhost"))

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful