]> Cypherpunks.ru repositories - nncp.git/blob - src/magic.go
Merge branch 'develop'
[nncp.git] / src / magic.go
1 /*
2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package nncp
19
20 import "fmt"
21
22 type Magic struct {
23         B    [8]byte
24         Name string
25         Till string
26 }
27
28 var (
29         MagicNNCPBv1 = Magic{
30                 B:    [8]byte{'N', 'N', 'C', 'P', 'B', 0, 0, 1},
31                 Name: "NNCPBv1 (EBlob v1)", Till: "1.0",
32         }
33         MagicNNCPBv2 = Magic{
34                 B:    [8]byte{'N', 'N', 'C', 'P', 'B', 0, 0, 2},
35                 Name: "NNCPBv2 (EBlob v2)", Till: "3.4",
36         }
37         MagicNNCPBv3 = Magic{
38                 B:    [8]byte{'N', 'N', 'C', 'P', 'B', 0, 0, 3},
39                 Name: "NNCPBv3 (EBlob v3)", Till: "now",
40         }
41         MagicNNCPDv1 = Magic{
42                 B:    [8]byte{'N', 'N', 'C', 'P', 'D', 0, 0, 1},
43                 Name: "NNCPDv1 (multicast discovery v1)", Till: "now",
44         }
45         MagicNNCPEv1 = Magic{
46                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 1},
47                 Name: "NNCPEv1 (encrypted packet v1)", Till: "0.12",
48         }
49         MagicNNCPEv2 = Magic{
50                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 2},
51                 Name: "NNCPEv2 (encrypted packet v2)", Till: "1.0",
52         }
53         MagicNNCPEv3 = Magic{
54                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 3},
55                 Name: "NNCPEv3 (encrypted packet v3)", Till: "3.4",
56         }
57         MagicNNCPEv4 = Magic{
58                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 4},
59                 Name: "NNCPEv4 (encrypted packet v4)", Till: "6.6.0",
60         }
61         MagicNNCPEv5 = Magic{
62                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 5},
63                 Name: "NNCPEv5 (encrypted packet v5)", Till: "now",
64         }
65         MagicNNCPSv1 = Magic{
66                 B:    [8]byte{'N', 'N', 'C', 'P', 'S', 0, 0, 1},
67                 Name: "NNCPSv1 (sync protocol v1)", Till: "now",
68         }
69         MagicNNCPMv1 = Magic{
70                 B:    [8]byte{'N', 'N', 'C', 'P', 'M', 0, 0, 1},
71                 Name: "NNCPMv1 (chunked .meta v1)", Till: "6.6.0",
72         }
73         MagicNNCPMv2 = Magic{
74                 B:    [8]byte{'N', 'N', 'C', 'P', 'M', 0, 0, 2},
75                 Name: "NNCPMv2 (chunked .meta v2)", Till: "now",
76         }
77         MagicNNCPPv1 = Magic{
78                 B:    [8]byte{'N', 'N', 'C', 'P', 'P', 0, 0, 1},
79                 Name: "NNCPPv1 (plain packet v1)", Till: "2.0",
80         }
81         MagicNNCPPv2 = Magic{
82                 B:    [8]byte{'N', 'N', 'C', 'P', 'P', 0, 0, 2},
83                 Name: "NNCPPv2 (plain packet v2)", Till: "4.1",
84         }
85         MagicNNCPPv3 = Magic{
86                 B:    [8]byte{'N', 'N', 'C', 'P', 'P', 0, 0, 3},
87                 Name: "NNCPPv3 (plain packet v3)", Till: "now",
88         }
89 )
90
91 func (m *Magic) TooOld() error {
92         return fmt.Errorf("%s format is unsupported (used till %s)", m.Name, m.Till)
93 }