forensiq

package module
v0.0.0-...-fe45e6c Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2016 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Forensiq

godoc license Build Status Coverage

Forensiq is a Go library interfacing Forensiq API.

Installing

go get -u github.com/dailymotion/forensiq

Usage

package main

import (
	"fmt"
	"log"
	"net"
	"time"

	"github.com/dailymotion/forensiq"
	"github.com/rs/xlog"
	"golang.org/x/net/context"
)

func main() {
	// create the context and a logger to it.
	ctx := context.Background()
	ctx = xlog.NewContext(ctx, xlog.New(xlog.Config{Output: xlog.NewConsoleOutput()}))

	// create a new forensiq object.
	fq := forensiq.New("http://api.forensiq.com", "xxx") // Replace xxx with your client key.

	// create a Forensiq Request.
	fqreq := forensiq.CheckRequest{
		IP:          net.ParseIP("8.8.8.8"),
		RequestType: "display",
		URL:         "http://www.dailymotion.com/video/x3llhsx_ces-2016-wired-s-favorite-gadgets-of-ces_tech",
		SellerID:    "123",
		SubID:       "78679676",
		Campaign:    "217673313",
		UserAgent:   "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36",
		CookieID:    "2acc8d3b1a08cf1dd19185d809d04737",
	}

	// give the request one second to complete
	ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
	defer cancel()

	// send the request to forensiq, the response is of type forensiq.CheckResponse
	fqresp, err := fq.Check(ctx, fqreq)
	if err != nil {
		log.Fatalf("error with the request to Forensiq: %s", err)
	}

	fmt.Printf("%#v", fqresp)
}

Running this should return the following:

forensiq.CheckResponse{RiskScore:0, SellerDomain:0, DomainViewed:0, DomainHidden:0, SellerViewed:0, SellerHidden:0, IPReputation:false, Proxy:false, AutomatedTraffic:false, HostingProvider:false, Spoofed:0, NonSuspect:true, TimeMS:2}

Licenses

All source code is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidClientKey is returned when the client key was not accepted by forensiq
	ErrInvalidClientKey = errors.New("the client key was not accepted by forensiq")
)

Functions

This section is empty.

Types

type CheckRequest

type CheckRequest struct {
	// IP is the visitor’s IP address. Required.
	IP net.IP
	// RequestType based on where the call is performed. Possible values are
	// click or display. Required
	RequestType string
	// URL is the URL  where the ad is placed. Optional
	URL string
	// SellerID is the ID you assign to your traffic sources/publishers.
	// Required
	SellerID string
	// SubID is the sub source or placement ID. Optional
	SubID string
	// Campaign is the campaign or creative ID. Optional
	Campaign string
	// UserAgent is user-agent string captured from the http headers passed by
	// the browser. Optional
	UserAgent string
	// CookieID is the id representing the user of the request.
	CookieID string
}

CheckRequest represents a request to the Forensiq API

type CheckResponse

type CheckResponse struct {
	// RiskScore represents the likelihood that an impression is fraudulent.
	RiskScore int `json:"riskScore"`
	// SellerDomain represents the ratio of impressions with riskScore of 65 or
	// above for a specified seller-domain combination.
	SellerDomain int `json:"sellerDomain"`
	// DomainViewed represents the ratio of ads viewed grouped by domain,
	// ranging from 0 (no ads viewed) to 100 (all ads viewed).
	DomainViewed int `json:"domainViewed"`
	// DomainHidden represents the ratio of ads likely hidden grouped by
	// domain, ranging from 0 (no ads hidden) to 100 (all ads hidden).
	DomainHidden int `json:"domainHidden"`
	// SellerViewed represents the ratio of ads viewed grouped by seller,
	// ranging from 0 (no ads viewed) to 100 (all ads viewed).
	SellerViewed int `json:"sellerViewed"`
	// SellerHidden represents the ratio of ads likely hidden grouped by
	// seller, ranging from 0 (no ads hidden) to 100 (all ads hidden).
	SellerHidden int `json:"sellerHidden"`
	// IPReputation is true if Forensiq have flagged high-risk activity from
	// the IP in the past (e.g. User Agent spoofing, IP manipulation etc.).
	IPReputation bool `json:"ipr"`
	// Proxy is true if IP is a proxy.
	Proxy bool `json:"pxy"`
	// AutomatedTraffic is true if malicious botnet and other types of
	// automated activity identified through real-time traffic pattern
	// analysis.
	AutomatedTraffic bool `json:"atf"`
	// HostingProvider Use of an ISP, which Forensiq recognized as a
	// hosting provider. Servers in hosting providers are used to send spam,
	// host malware, botnet controllers, or engage in other suspect activities.
	HostingProvider bool `json:"hst"`
	// Spoofed is true if Forensiq see patterns of spoofing within the user’s
	// device. This characteristic is limited to analyzing the user agent of
	// the user within the pre-bid environment.
	Spoofed int
	// NonSuspect is true if the client is not suspected of being a bot
	NonSuspect bool `json:"nonSuspect"`
	// TimeMS represents the time it took for the request to complete in
	// Millisecond.
	TimeMS int `json:"timeMs"`
}

CheckResponse is returned by Forensiq API.

type Forensiq

type Forensiq struct {
	// ClientKey is an authentication key for each client’s account provided by
	// Forensiq. Required.
	ClientKey string
	// Host is the host where the Forensiq API is available at.
	Host string
	// contains filtered or unexported fields
}

Forensiq represents a forensiq API client.

func New

func New(host, clientKey string) *Forensiq

New returns a new Forensiq initialized with given host and clientKey and use http.DefaultClient as the HTTP client.

func (*Forensiq) Check

func (f *Forensiq) Check(ctx context.Context, creq CheckRequest) (CheckResponse, error)

Check get the riskScore and aggregate characteristics.

func (*Forensiq) Ready

func (f *Forensiq) Ready(ctx context.Context) (bool, error)

Ready returns true if the API is ready

func (*Forensiq) SetHTTPClient

func (f *Forensiq) SetHTTPClient(hc *http.Client)

SetHTTPClient sets a custom HTTP Client to use when sending requests to forensiq. By default http.DefaultClient is used.

Jump to

Keyboard shortcuts

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