forked from turbobytes/cdnfinder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheaderguess.go
43 lines (40 loc) · 1.01 KB
/
headerguess.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cdnfinder
import (
"net/http"
"strings"
)
//TODO: define this somehow in json...
func headerguessStr(hdr *http.Header) string {
//Cloudflare advertises a custom Server header
if strings.ToLower(hdr.Get("Server")) == "cloudflare-nginx" {
return "Cloudflare"
}
//China cache sends a Powered-By-Chinacache header
if hdr.Get("powered-by-chinacache") != "" {
return "ChinaCache"
}
//OnApp edge servers use X-Edge-Location to indicate the location
if hdr.Get("x-edge-location") != "" {
return "OnApp"
}
//CloudFront adds in some custom tracking id
if hdr.Get("x-amz-cf-id") != "" {
return "Amazon Cloudfront"
}
//Bitgravity adds edge hostname to Via header
if strings.Contains(strings.ToLower(hdr.Get("via")), "bitgravity.com") {
return "Bitgravity"
}
//Skypark sends a X header with their brand name
if hdr.Get("X-CDN-Provider") == "SkyparkCDN" {
return "Skypark"
}
return ""
}
func headerguess(hdr *http.Header) *string {
cdn := headerguessStr(hdr)
if cdn != "" {
return &cdn
}
return nil
}