Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Term.cs
1using System;
2using System.Collections.Generic;
3using System.Net;
5
6namespace Waher.Security.SPF
7{
11 public enum SpfQualifier
12 {
16 Pass,
17
21 Fail,
22
26 SoftFail,
27
31 Neutral
32 }
33
37 public class Term
38 {
39 internal string s = null;
40 internal int len = 0;
41 internal int pos = 0;
42 internal int dnsLookupsLeft = 10;
43 internal readonly string sender;
44 internal string domain;
45 internal readonly string helloDomain;
46 internal readonly string hostDomain;
47 internal readonly IPAddress ip;
48
61 public Term(string Sender, string Domain, IPAddress Ip, string HelloDomain,
62 string HostDomain)
63 {
64 this.sender = Sender;
65 this.domain = Domain;
66 this.ip = Ip;
67 this.helloDomain = HelloDomain;
68 this.hostDomain = HostDomain;
69 }
70
75 public void Reset(string String)
76 {
77 this.s = String?.Trim() ?? string.Empty;
78 this.len = this.s.Length;
79 this.pos = 0;
80 }
81
82 internal void SkipWhiteSpace()
83 {
84 while (this.pos < this.len && this.s[this.pos] <= ' ')
85 this.pos++;
86 }
87
88 internal char PeekNextChar()
89 {
90 if (this.pos >= this.len)
91 return (char)0;
92 else
93 return this.s[this.pos];
94 }
95
96 internal char NextChar()
97 {
98 if (this.pos >= this.len)
99 throw new Exception("SPF syntax error.");
100
101 return this.s[this.pos++];
102 }
103
104 internal int NextInteger()
105 {
106 int Start = this.pos;
107
108 while (char.IsDigit(this.PeekNextChar()))
109 this.pos++;
110
111 return int.Parse(this.s.Substring(Start, this.pos - Start));
112 }
113
114 internal string NextLabel()
115 {
116 int Start = this.pos;
117 char ch;
118
119 if (char.IsLetter(ch = this.PeekNextChar()))
120 {
121 this.pos++;
122
123 while (char.IsLetter(ch = this.PeekNextChar()) || char.IsDigit(ch) ||
124 ch == '-' || ch == '_' || ch == '.')
125 {
126 this.pos++;
127 }
128 }
129
130 return this.s.Substring(Start, this.pos - Start);
131 }
132
133 }
134}
Abstract base class for IP-based SPF mechanisms.
Definition: Ip.cs:12
void Reset(string String)
Resets the string representation of the term.
Definition: Term.cs:75
Term(string Sender, string Domain, IPAddress Ip, string HelloDomain, string HostDomain)
SPF Term
Definition: Term.cs:61
SpfQualifier
SPF Mechanism qualifier
Definition: Term.cs:12