]> Cypherpunks.ru repositories - nncp.git/blob - src/magic.go
Raise copyright years
[nncp.git] / src / magic.go
1 /*
2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2022 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 (
21         "errors"
22         "fmt"
23 )
24
25 type Magic struct {
26         B    [8]byte
27         Name string
28         Till string
29 }
30
31 var (
32         MagicNNCPAv1 = Magic{
33                 B:    [8]byte{'N', 'N', 'C', 'P', 'A', 0, 0, 1},
34                 Name: "NNCPAv1 (area packet v1)", Till: "now",
35         }
36         MagicNNCPBv1 = Magic{
37                 B:    [8]byte{'N', 'N', 'C', 'P', 'B', 0, 0, 1},
38                 Name: "NNCPBv1 (EBlob v1)", Till: "1.0",
39         }
40         MagicNNCPBv2 = Magic{
41                 B:    [8]byte{'N', 'N', 'C', 'P', 'B', 0, 0, 2},
42                 Name: "NNCPBv2 (EBlob v2)", Till: "3.4",
43         }
44         MagicNNCPBv3 = Magic{
45                 B:    [8]byte{'N', 'N', 'C', 'P', 'B', 0, 0, 3},
46                 Name: "NNCPBv3 (EBlob v3)", Till: "now",
47         }
48         MagicNNCPDv1 = Magic{
49                 B:    [8]byte{'N', 'N', 'C', 'P', 'D', 0, 0, 1},
50                 Name: "NNCPDv1 (multicast discovery v1)", Till: "now",
51         }
52         MagicNNCPEv1 = Magic{
53                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 1},
54                 Name: "NNCPEv1 (encrypted packet v1)", Till: "0.12",
55         }
56         MagicNNCPEv2 = Magic{
57                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 2},
58                 Name: "NNCPEv2 (encrypted packet v2)", Till: "1.0",
59         }
60         MagicNNCPEv3 = Magic{
61                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 3},
62                 Name: "NNCPEv3 (encrypted packet v3)", Till: "3.4",
63         }
64         MagicNNCPEv4 = Magic{
65                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 4},
66                 Name: "NNCPEv4 (encrypted packet v4)", Till: "6.6.0",
67         }
68         MagicNNCPEv5 = Magic{
69                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 5},
70                 Name: "NNCPEv5 (encrypted packet v5)", Till: "7.7.0",
71         }
72         MagicNNCPEv6 = Magic{
73                 B:    [8]byte{'N', 'N', 'C', 'P', 'E', 0, 0, 6},
74                 Name: "NNCPEv6 (encrypted packet v6)", Till: "now",
75         }
76         MagicNNCPSv1 = Magic{
77                 B:    [8]byte{'N', 'N', 'C', 'P', 'S', 0, 0, 1},
78                 Name: "NNCPSv1 (sync protocol v1)", Till: "now",
79         }
80         MagicNNCPMv1 = Magic{
81                 B:    [8]byte{'N', 'N', 'C', 'P', 'M', 0, 0, 1},
82                 Name: "NNCPMv1 (chunked .meta v1)", Till: "6.6.0",
83         }
84         MagicNNCPMv2 = Magic{
85                 B:    [8]byte{'N', 'N', 'C', 'P', 'M', 0, 0, 2},
86                 Name: "NNCPMv2 (chunked .meta v2)", Till: "now",
87         }
88         MagicNNCPPv1 = Magic{
89                 B:    [8]byte{'N', 'N', 'C', 'P', 'P', 0, 0, 1},
90                 Name: "NNCPPv1 (plain packet v1)", Till: "2.0",
91         }
92         MagicNNCPPv2 = Magic{
93                 B:    [8]byte{'N', 'N', 'C', 'P', 'P', 0, 0, 2},
94                 Name: "NNCPPv2 (plain packet v2)", Till: "4.1",
95         }
96         MagicNNCPPv3 = Magic{
97                 B:    [8]byte{'N', 'N', 'C', 'P', 'P', 0, 0, 3},
98                 Name: "NNCPPv3 (plain packet v3)", Till: "now",
99         }
100
101         BadMagic error = errors.New("Unknown magic number")
102 )
103
104 func (m *Magic) TooOld() error {
105         return fmt.Errorf("%s format is unsupported (used till %s)", m.Name, m.Till)
106 }