├── .gitignore ├── Dockerfile ├── go.mod ├── login.go ├── go.sum ├── cert.go ├── README.md ├── .github └── workflows │ └── docker-publish.yml ├── main.go └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | build/ 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.18 2 | 3 | WORKDIR /usr/src/app 4 | 5 | # pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change 6 | COPY go.mod go.sum ./ 7 | RUN go mod download && go mod verify 8 | 9 | COPY . . 10 | RUN go build -v -o /usr/local/bin/app ./... 11 | 12 | ENTRYPOINT ["app"] 13 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module ieb.im/gotvrelay 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/gorilla/mux v1.8.0 7 | github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 8 | golang.org/x/crypto v0.0.0-20220408190544-5352b0902921 9 | ) 10 | 11 | require ( 12 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect 13 | golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71 // indirect 14 | golang.org/x/text v0.3.6 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /login.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io" 7 | "net/http" 8 | ) 9 | 10 | type Crediential struct { 11 | Login string `json:"Login"` 12 | Password string `json:"Password"` 13 | } 14 | 15 | const LoginUrl = "https://f1-api.jeb.nom.za/authenticate" 16 | 17 | func handleLogin(w http.ResponseWriter, r *http.Request) { 18 | var p Crediential 19 | 20 | if login != "" && password != "" { 21 | p.Login = login 22 | p.Password = password 23 | } else { 24 | err := json.NewDecoder(r.Body).Decode(&p) 25 | if err != nil { 26 | http.Error(w, err.Error(), http.StatusBadRequest) 27 | return 28 | } 29 | } 30 | 31 | jsonStr, _ := json.Marshal(p) 32 | req, _ := http.NewRequest("POST", LoginUrl, bytes.NewBuffer(jsonStr)) 33 | for k, vv := range r.Header { 34 | for _, v := range vv { 35 | req.Header.Add(k, v) 36 | } 37 | } 38 | client := &http.Client{} 39 | resp, _ := client.Do(req) 40 | 41 | for k, vv := range resp.Header { 42 | for _, v := range vv { 43 | w.Header().Add(k, v) 44 | } 45 | } 46 | w.WriteHeader(resp.StatusCode) 47 | _, _ = io.Copy(w, resp.Body) 48 | _ = resp.Body.Close() 49 | } 50 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= 2 | github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= 3 | github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= 4 | github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 5 | golang.org/x/crypto v0.0.0-20220408190544-5352b0902921 h1:iU7T1X1J6yxDr0rda54sWGkHgOp5XJrqm79gcNlC2VM= 6 | golang.org/x/crypto v0.0.0-20220408190544-5352b0902921/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 7 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= 8 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 9 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 10 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 11 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 12 | golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71 h1:X/2sJAybVknnUnV7AD2HdT6rm2p5BP6eH2j+igduWgk= 13 | golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 14 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 15 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= 16 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 17 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 18 | -------------------------------------------------------------------------------- /cert.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/rand" 5 | "crypto/rsa" 6 | "crypto/tls" 7 | "crypto/x509" 8 | "crypto/x509/pkix" 9 | "math/big" 10 | "net" 11 | "sync" 12 | "time" 13 | ) 14 | 15 | const RSABits = 2048 16 | const ValidFor = time.Hour * 1440 17 | 18 | var certCache sync.Map 19 | 20 | func GetSelfSignedCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) { 21 | if cert, ok := certCache.Load(clientHello.ServerName); ok { 22 | return cert.(*tls.Certificate), nil 23 | } 24 | priv, err := rsa.GenerateKey(rand.Reader, RSABits) 25 | if err != nil { 26 | return nil, err 27 | } 28 | 29 | notBefore := time.Now() 30 | notAfter := notBefore.Add(ValidFor) 31 | 32 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) 33 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | template := x509.Certificate{ 39 | SerialNumber: serialNumber, 40 | Subject: pkix.Name{ 41 | Organization: []string{"Acme Co"}, 42 | }, 43 | NotBefore: notBefore, 44 | NotAfter: notAfter, 45 | KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, 46 | ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, 47 | BasicConstraintsValid: true, 48 | } 49 | 50 | host := clientHello.ServerName 51 | if ip := net.ParseIP(host); ip != nil { 52 | template.IPAddresses = append(template.IPAddresses, ip) 53 | } else { 54 | template.DNSNames = append(template.DNSNames, host) 55 | } 56 | 57 | derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) 58 | if err != nil { 59 | return nil, err 60 | } 61 | 62 | cert := &tls.Certificate{ 63 | Certificate: [][]byte{derBytes}, 64 | PrivateKey: priv, 65 | } 66 | certCache.Store(clientHello.ServerName, cert) 67 | return cert, err 68 | } 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # F1WebViewer-SelfHosted 2 | 3 | Self-hosted reverse-proxy for F1 web viewer and includes a web server at port 13331. You can also run this proxy on a server if your home country doesn't have F1TV. 4 | 5 | ## Installation and Usage 6 | 7 | Currently authentication and Reese84 Requests are routed through the public website as the solution might be immature. 8 | 9 | If you are experiencing lag / stutter or other issues locally, try using Bitmovin Player in the Setting Tab. License is NOT required for local deploys. 10 | 11 | ### Compiled Binary 12 | 13 | Download the latest binary [from the Releases](https://github.com/iebb/F1WebViewer-SelfHosted/releases) and run. You may need to run `chmod +x ` to make the file executable on Mac / Linux 14 | 15 | ### Compile / Run from Source 16 | 17 | Download and install Go, then 18 | 19 | ```bash 20 | git clone https://github.com/iebb/F1WebViewer-SelfHosted.git 21 | cd F1WebViewer-SelfHosted 22 | go run . 23 | #or go build . 24 | ``` 25 | 26 | ### Running on a Server (Requires SSL to make DRM work) 27 | 28 | Streams with DRM (Encrypted Media) require secure context to work. If you want to run this on a server (aka not on localhost), you have to connect using HTTPS to watch LIVE content. 29 | 30 | This tool provides some easy-to-use SSL options, or you can still manage yourself. 31 | 32 | ## Custom Arguments 33 | 34 | | Command | Notes 35 | :------------------ | :--------- 36 | | `-ssl` | SSL support via Lets Encrypt. Requires a public IP and port 80 being open to fetch the certificate 37 | | `-listen localhost:80` | Use a custom `host:port` instead of the default `localhost:13331` 38 | | `-self-sign` | Issue and use a self-signed SSL certificate. Will display a warning in browsers 39 | 40 | Running with `-ssl` or `-self-sign` requires you opening the browser manually, as these commands are supposed to run in a server rather than your PC. 41 | 42 | ## Screenshots 43 | 44 | ![image](https://user-images.githubusercontent.com/2127498/162486955-ca58805d-da15-43e0-9b4a-a54a31401a10.png) 45 | -------------------------------------------------------------------------------- /.github/workflows/docker-publish.yml: -------------------------------------------------------------------------------- 1 | name: Docker 2 | 3 | # This workflow uses actions that are not certified by GitHub. 4 | # They are provided by a third-party and are governed by 5 | # separate terms of service, privacy policy, and support 6 | # documentation. 7 | 8 | on: 9 | schedule: 10 | - cron: '23 13 * * *' 11 | push: 12 | branches: [ master ] 13 | # Publish semver tags as releases. 14 | tags: [ 'v*.*.*' ] 15 | pull_request: 16 | branches: [ master ] 17 | 18 | env: 19 | # Use docker.io for Docker Hub if empty 20 | REGISTRY: ghcr.io 21 | # github.repository as / 22 | IMAGE_NAME: ${{ github.repository }} 23 | 24 | 25 | jobs: 26 | build: 27 | 28 | runs-on: ubuntu-latest 29 | permissions: 30 | contents: read 31 | packages: write 32 | # This is used to complete the identity challenge 33 | # with sigstore/fulcio when running outside of PRs. 34 | id-token: write 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@v3 39 | 40 | # Install the cosign tool except on PR 41 | # https://github.com/sigstore/cosign-installer 42 | - name: Install cosign 43 | if: github.event_name != 'pull_request' 44 | uses: sigstore/cosign-installer@d6a3abf1bdea83574e28d40543793018b6035605 45 | with: 46 | cosign-release: 'v1.7.1' 47 | 48 | 49 | # Workaround: https://github.com/docker/build-push-action/issues/461 50 | - name: Setup Docker buildx 51 | uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf 52 | 53 | # Login against a Docker registry except on PR 54 | # https://github.com/docker/login-action 55 | - name: Log into registry ${{ env.REGISTRY }} 56 | if: github.event_name != 'pull_request' 57 | uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c 58 | with: 59 | registry: ${{ env.REGISTRY }} 60 | username: ${{ github.actor }} 61 | password: ${{ secrets.GITHUB_TOKEN }} 62 | 63 | # Extract metadata (tags, labels) for Docker 64 | # https://github.com/docker/metadata-action 65 | - name: Extract Docker metadata 66 | id: meta 67 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 68 | with: 69 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 70 | 71 | # Build and push Docker image with Buildx (don't push on PR) 72 | # https://github.com/docker/build-push-action 73 | - name: Build and push Docker image 74 | id: build-and-push 75 | uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a 76 | with: 77 | context: . 78 | push: ${{ github.event_name != 'pull_request' }} 79 | tags: ${{ steps.meta.outputs.tags }} 80 | labels: ${{ steps.meta.outputs.labels }} 81 | 82 | # Sign the resulting Docker image digest except on PRs. 83 | # This will only write to the public Rekor transparency log when the Docker 84 | # repository is public to avoid leaking data. If you would like to publish 85 | # transparency data even for private images, pass --force to cosign below. 86 | # https://github.com/sigstore/cosign 87 | - name: Sign the published Docker image 88 | if: ${{ github.event_name != 'pull_request' }} 89 | env: 90 | COSIGN_EXPERIMENTAL: "true" 91 | # This step uses the identity token to provision an ephemeral certificate 92 | # against the sigstore community Fulcio instance. 93 | run: cosign sign ${{ steps.meta.outputs.tags }}@${{ steps.build-and-push.outputs.digest }} 94 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/tls" 5 | "flag" 6 | "fmt" 7 | "github.com/gorilla/mux" 8 | "github.com/pkg/browser" 9 | "golang.org/x/crypto/acme/autocert" 10 | "log" 11 | "net/http" 12 | "net/http/httputil" 13 | "net/url" 14 | "regexp" 15 | "strings" 16 | ) 17 | 18 | var builtInSSL = false 19 | var selfSSL = false 20 | var listenAddr = "localhost:13331" 21 | var login = "" 22 | var password = "" 23 | 24 | func init() { 25 | flag.BoolVar(&builtInSSL, "ssl", false, 26 | "built-in ssl support. this requires a public IP, and port 80 being available in order to fetch the certs", 27 | ) 28 | flag.BoolVar(&selfSSL, "self-sign", false, 29 | "self-signed ssl support. would display a warning on browsers", 30 | ) 31 | flag.StringVar(&listenAddr, "listen", "localhost:13331", "which IP and port to listen?") 32 | flag.StringVar(&login, "login", "", "server-side login") 33 | flag.StringVar(&password, "password", "", "server-side password") 34 | } 35 | 36 | func main() { 37 | flag.Parse() 38 | 39 | stripDomain := regexp.MustCompile(`Domain=[^;]+; `) 40 | handler := func(w http.ResponseWriter, r *http.Request) { 41 | log.Printf("%s API - %s\n", r.RemoteAddr, r.URL.String()) 42 | varUrl := mux.Vars(r)["url"] 43 | pathCleaned := !strings.Contains(varUrl, "://") 44 | if pathCleaned { 45 | varUrl = strings.ReplaceAll(varUrl, ":/", "://") 46 | } 47 | remote, _ := url.Parse(varUrl) 48 | r.URL.Scheme = remote.Scheme 49 | r.URL.Path = remote.Path 50 | r.Host = remote.Host 51 | remote.Path = "" 52 | r.Header.Del("Referer") 53 | r.Header.Del("Origin") 54 | proxy := httputil.NewSingleHostReverseProxy(remote) 55 | proxy.ModifyResponse = func(resp *http.Response) error { 56 | if setCookie := resp.Header.Get("Set-Cookie"); setCookie != "" { 57 | remotePath := remote.String() 58 | if pathCleaned { 59 | remotePath = strings.ReplaceAll(remotePath, "://", ":/") 60 | } 61 | setCookie = strings.ReplaceAll(setCookie, "Path=/", "Path=/proxy/"+remotePath+"/") 62 | setCookie = strings.ReplaceAll(setCookie, ";SameSite=None;Secure", "") 63 | setCookie = stripDomain.ReplaceAllString(setCookie, "") 64 | resp.Header.Set("Set-Cookie", setCookie) 65 | } 66 | return nil 67 | } 68 | proxy.ServeHTTP(w, r) 69 | } 70 | 71 | staticRemote, _ := url.Parse("https://f1vp.netlify.app") 72 | staticProxy := httputil.NewSingleHostReverseProxy(staticRemote) 73 | serverSideLogin := 0 74 | if login != "" && password != "" { 75 | serverSideLogin = 1 76 | } 77 | staticProxy.ModifyResponse = func(resp *http.Response) (err error) { 78 | resp.Header.Add("Set-Cookie", fmt.Sprintf("server_side_login=%d; Max-Age=86400; Path=/", serverSideLogin)) 79 | return nil 80 | } 81 | staticHandler := func(w http.ResponseWriter, r *http.Request) { 82 | log.Printf("%s FE* - %s\n", r.RemoteAddr, r.URL.String()) 83 | r.Host = staticRemote.Host 84 | staticProxy.ServeHTTP(w, r) 85 | } 86 | 87 | r := mux.NewRouter() 88 | r.HandleFunc("/proxy/{url:https?://?.*}", handler) 89 | r.PathPrefix("/authenticate").HandlerFunc(handleLogin) 90 | r.PathPrefix("/").HandlerFunc(staticHandler) 91 | r.SkipClean(true) 92 | 93 | if builtInSSL { 94 | certManager := autocert.Manager{ 95 | Prompt: autocert.AcceptTOS, 96 | Cache: autocert.DirCache("certs"), 97 | } 98 | 99 | server := &http.Server{ 100 | Addr: listenAddr, 101 | TLSConfig: &tls.Config{ 102 | GetCertificate: certManager.GetCertificate, 103 | }, 104 | Handler: r, 105 | } 106 | go http.ListenAndServe(":http", certManager.HTTPHandler(nil)) 107 | log.Fatal(server.ListenAndServeTLS("", "")) 108 | } else if selfSSL { 109 | 110 | server := &http.Server{ 111 | Addr: listenAddr, 112 | TLSConfig: &tls.Config{ 113 | GetCertificate: GetSelfSignedCertificate, 114 | }, 115 | Handler: r, 116 | } 117 | log.Fatal(server.ListenAndServeTLS("", "")) 118 | } else { 119 | _ = browser.OpenURL(fmt.Sprintf("http://%s/", listenAddr)) 120 | log.Println("Reverse Proxy Server running at " + listenAddr + "\n") 121 | log.Fatal(http.ListenAndServe(listenAddr, r)) 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------