├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── dmca └── dmca.go ├── main.go ├── package.json └── versions ├── current └── history /.gitignore: -------------------------------------------------------------------------------- 1 | auth.token 2 | node_modules 3 | dmca/notices/ 4 | dmca/bindata.go 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Protocol Labs, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | local="http://localhost:8080/ipfs/" 2 | gway="https://ipfs.io/ipfs/" 3 | domain="refs.ipfs.io" 4 | record="@" 5 | 6 | publish: 7 | rm -rf dmca/notices 8 | git clone https://github.com/ipfs/refs-denylists-dmca.git dmca/notices 9 | go-bindata -pkg dmca -o dmca/bindata.go -ignore '^dmca/notices/\.git' dmca/notices/... 10 | 11 | go run main.go -current=$(shell cat versions/current) | tail -n1 >versions/current 12 | cat versions/current >>versions/history 13 | @export hash=`cat versions/current`; \ 14 | echo ""; \ 15 | echo "new version:"; \ 16 | echo "- $(local)$$hash"; \ 17 | echo "- $(gway)$$hash"; \ 18 | echo ""; \ 19 | echo "next:"; \ 20 | echo "- pin $$hash"; \ 21 | echo "- make dnslink"; 22 | 23 | # Only run after publish, or there won't be a path to set. 24 | dnslink: node_modules 25 | DIGITAL_OCEAN=$(shell cat $(HOME)/.protocol/digitalocean.key) node_modules/.bin/dnslink-deploy \ 26 | --domain=$(domain) --record=$(record) --path=/ipfs/$(shell cat versions/current) 27 | 28 | node_modules: package.json 29 | npm install 30 | touch node_modules 31 | 32 | .PHONY: build dnslink 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## This repository has been archived! 2 | *This IPFS-related repository has been archived, and all issues are therefore frozen.* If you want to ask a question or open/continue a discussion related to this repo, please visit the [official IPFS forums](https://discuss.ipfs.io). 3 | 4 | We archive repos for one or more of the following reasons: 5 | - Code or content is unmaintained, and therefore might be broken 6 | - Content is outdated, and therefore may mislead readers 7 | - Code or content evolved into something else and/or has lived on in a different place 8 | - The repository or project is not active in general 9 | 10 | Please note that in order to keep the primary IPFS GitHub org tidy, most archived repos are moved into the [ipfs-inactive](https://github.com/ipfs-inactive) org. 11 | 12 | If you feel this repo should **not** be archived (or portions of it should be moved to a non-archived repo), please [reach out](https://ipfs.io/help) and let us know. Archiving can always be reversed if needed. 13 | 14 | # refs 15 | 16 | > DMCA notices, and tools for publishing them 17 | 18 | [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) 19 | [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) 20 | [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) 21 | [![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) 22 | 23 | Tool for building and publishing the DAG at https://ipfs.io/refs 24 | 25 | Renders a DAG from various data sources: 26 | 27 | - DMCA notices served for the gateway at ipfs.io -- https://github.com/ipfs/refs-denylists-dmca 28 | - TODO: Content archived on our storage hosts -- https://github.com/ipfs/refs-solarnet-storage 29 | 30 | ## Table of Contents 31 | 32 | - [Install](#install) 33 | - [Usage](#usage) 34 | - [Contribute](#contribute) 35 | - [License](#license) 36 | 37 | ## Install 38 | 39 | Clone this repo. Depends on [npm](https://npmjs.com) and [node.js](https://nodejs.com). 40 | 41 | ## Usage 42 | 43 | ```sh 44 | # render, add, and publish the denylist 45 | $ make build && make publish 46 | $ git add versions/ && git commit -m Publish && git push 47 | 48 | # update the TXT record for refs.ipfs.io 49 | $ npm install && make dnslink 50 | # wait for it to propagate 51 | $ watch dig TXT refs.ipfs.io 52 | ``` 53 | 54 | ## Contribute 55 | 56 | Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/refs/issues)! 57 | 58 | This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). 59 | 60 | [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md) 61 | 62 | ## License 63 | 64 | [MIT](LICENSE) 65 | -------------------------------------------------------------------------------- /dmca/dmca.go: -------------------------------------------------------------------------------- 1 | package dmca 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | shell "github.com/whyrusleeping/ipfs-shell" 7 | "html/template" 8 | "io" 9 | "strings" 10 | ) 11 | 12 | type noticeData struct { 13 | Body string 14 | Keys []string 15 | } 16 | 17 | var noticeTemplate *template.Template 18 | var noticeBytes = ` 19 | 20 | 21 | 22 | 23 | Unavailable for Legal Reasons 24 | 25 | 26 | {{ .Body }} 27 |

Affected Objects

28 | 33 | 34 | 35 | ` 36 | 37 | func keysAndNotice(dir string) ([]string, io.Reader, error) { 38 | kpath := dir + "/keys" 39 | npath := dir + "/notice.md" 40 | keys := []string{} 41 | 42 | kbytes, err := Asset(kpath) 43 | if err != nil { 44 | return nil, nil, err 45 | } 46 | s := bufio.NewScanner(strings.NewReader(string(kbytes))) 47 | for s.Scan() { 48 | keys = append(keys, s.Text()) 49 | } 50 | 51 | nbytes, err := Asset(npath) 52 | if err != nil { 53 | return nil, nil, err 54 | } 55 | ndata := ¬iceData{ 56 | Keys: keys, 57 | Body: string(nbytes), 58 | } 59 | nreader, nwriter := io.Pipe() 60 | go func() { 61 | noticeTemplate.Execute(nwriter, ndata) 62 | defer nwriter.Close() 63 | }() 64 | 65 | return keys, nreader, nil 66 | } 67 | 68 | func addDenylist(srcpath string, sh *shell.Shell) (string, error) { 69 | dirs, err := AssetDir(srcpath) 70 | if err != nil { 71 | return "", err 72 | } 73 | 74 | h, err := sh.NewObject("unixfs-dir") 75 | if err != nil { 76 | return "", err 77 | } 78 | 79 | for _, dirname := range dirs { 80 | keys, nreader, err := keysAndNotice(srcpath + "/" + dirname) 81 | if err != nil { 82 | return "", err 83 | } 84 | 85 | n, err := sh.Add(nreader) 86 | if err != nil { 87 | return "", err 88 | } 89 | 90 | for i, k := range keys { 91 | n, err = sh.PatchLink(n, fmt.Sprintf("object-%d", i), k, true) 92 | if err != nil { 93 | return "", err 94 | } 95 | } 96 | 97 | h, err = sh.PatchLink(h, dirname, n, true) 98 | if err != nil { 99 | return "", err 100 | } 101 | } 102 | 103 | return h, nil 104 | } 105 | 106 | func AddDenylist(sh *shell.Shell) (string, error) { 107 | noticeTemplate = template.Must(template.New("notice").Parse(string(noticeBytes))) 108 | 109 | h, err := addDenylist("dmca/notices", sh) 110 | if err != nil { 111 | return "", err 112 | } 113 | 114 | return h, nil 115 | } 116 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | dmca "github.com/ipfs/refs/dmca" 5 | shell "github.com/whyrusleeping/ipfs-shell" 6 | 7 | "flag" 8 | "fmt" 9 | "log" 10 | ) 11 | 12 | func addSkeleton(sh *shell.Shell, dmca string) (string, error) { 13 | hdenylists, err := sh.NewObject("unixfs-dir") 14 | if err != nil { 15 | return "", err 16 | } 17 | hdenylists, err = sh.PatchLink(hdenylists, "dmca", dmca, true) 18 | if err != nil { 19 | return "", err 20 | } 21 | hlists, err := sh.NewObject("unixfs-dir") 22 | if err != nil { 23 | return "", err 24 | } 25 | hlists, err = sh.PatchLink(hlists, "denylists", hdenylists, true) 26 | if err != nil { 27 | return "", err 28 | } 29 | hroot, err := sh.NewObject("unixfs-dir") 30 | if err != nil { 31 | return "", err 32 | } 33 | hroot, err = sh.PatchLink(hroot, "lists", hlists, true) 34 | if err != nil { 35 | return "", err 36 | } 37 | return hroot, nil 38 | } 39 | 40 | func addPrevious(sh *shell.Shell, h string, c string) (string, error) { 41 | cur, err := sh.ResolvePath(c) 42 | if err != nil { 43 | log.Fatalf("could not resolve current version: %s", err) 44 | } 45 | prev, err := sh.ResolvePath(c + "/previous") 46 | if err == nil { 47 | h, err = sh.PatchLink(h, "previous", prev, true) 48 | if err != nil { 49 | return "", err 50 | } 51 | } 52 | 53 | if h != cur { 54 | h, err = sh.PatchLink(h, "previous", cur, true) 55 | if err != nil { 56 | return "", err 57 | } 58 | } 59 | 60 | return h, nil 61 | } 62 | 63 | func main() { 64 | u := flag.String("uri", "127.0.0.1:5001", "the IPFS API endpoint to use") 65 | c := flag.String("current", "/ipns/refs.ipfs.io", "add links to previous versions") 66 | flag.Parse() 67 | 68 | sh := shell.NewShell(*u) 69 | 70 | h, err := dmca.AddDenylist(sh) 71 | if err != nil { 72 | log.Fatalf("dmca.AddDenylist: %s", err) 73 | } 74 | 75 | if len(*c) > 0 { 76 | p, err := addPrevious(sh, h, *c+"/lists/denylists/dmca") 77 | if err != nil { 78 | log.Printf("could not add previous link: %s\n", err) 79 | } else { 80 | h = p 81 | } 82 | } 83 | 84 | h, err = addSkeleton(sh, h) 85 | if err != nil { 86 | log.Fatalf("main.addSkeleton: %s", err) 87 | } 88 | 89 | fmt.Println(h) 90 | } 91 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lists-denylists-dmca", 3 | "private": true, 4 | "dependencies": { 5 | }, 6 | "devDependencies": { 7 | "dnslink-deploy": "^1.0.1" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /versions/current: -------------------------------------------------------------------------------- 1 | QmUDqAEnDRcZzVjJjFjxBm8b9Z4zDtUY4aboATg2V29hJ5 2 | -------------------------------------------------------------------------------- /versions/history: -------------------------------------------------------------------------------- 1 | QmUDqAEnDRcZzVjJjFjxBm8b9Z4zDtUY4aboATg2V29hJ5 2 | --------------------------------------------------------------------------------