rootmesession

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2020 License: BSD-3-Clause Imports: 5 Imported by: 0

README

RootMeSession

Description

Simple way to make an http session in go for root-me.org.
Just to avoid handling the cookies manually, it's replaced by a login prompt when starting the program.
⚠ It is required to login to the website first, then run the program.

Example

package main

import (
    "log"
    rms "gitlab.com/worstone2/rootmesession"
)

func main() {
    // connect and create the sessionn for root-me.org.
    client, err := rms.Connect()
    if err != nil {
        log.Fatal(err)
    }

    // now do stuff with `client` just like a regular `*http.Client`
    // ...
}

Note

This should be used only by those who understand what it is and how to do but just look for a shortcut.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect() (*http.Client, error)

Connect is the root-me.org connection, it instanciates the needed cookies in order to persist the session.

Example
package main

import (
	"log"
	"net/http"

	"gitlab.com/worstone2/rootmesession"
)

func main() {
	url := "https://www.root-me.org/fr/Challenges/"

	// connect and create the sessionn for root-me.org.
	client, err := rootmesession.Connect()
	if err != nil {
		log.Fatal(err)
	}

	// Errors should be handled
	req, _ := http.NewRequest("GET", url, nil)
	res, _ := client.Do(req)
	log.Println("Response :", res.StatusCode)

	client.CloseIdleConnections()
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL