-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from ooni/add-support-for-parsing-echcheck
Add support for parsing echcheck related metadata in pipeline
- Loading branch information
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from dataclasses import dataclass | ||
from typing import List, Optional | ||
|
||
from oonidata.models.nettests.web_connectivity import WebConnectivityControl | ||
|
||
from ...compat import add_slots | ||
from ..dataformats import ( | ||
BaseTestKeys, | ||
DNSQuery, | ||
NetworkEvent, | ||
TCPConnect, | ||
TLSHandshake, | ||
) | ||
from oonidata.models.nettests.base_measurement import BaseMeasurement | ||
|
||
|
||
@add_slots | ||
@dataclass | ||
class ECHCheckTestKeys(BaseTestKeys): | ||
tls_handshakes: Optional[List[TLSHandshake]] = None | ||
control: Optional[TLSHandshake] = None | ||
target: Optional[TLSHandshake] = None | ||
network_events: Optional[List[NetworkEvent]] = None | ||
queries: Optional[List[DNSQuery]] = None | ||
tcp_connect: Optional[List[TCPConnect]] = None | ||
|
||
|
||
@add_slots | ||
@dataclass | ||
class ECHCheck(BaseMeasurement): | ||
__test_name__ = "echcheck" | ||
|
||
test_keys: ECHCheckTestKeys |
38 changes: 38 additions & 0 deletions
38
oonipipeline/src/oonipipeline/transforms/nettests/echcheck.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import List, Tuple | ||
|
||
from oonidata.models.nettests import ECHCheck | ||
from oonidata.models.observations import WebObservation | ||
|
||
from ..measurement_transformer import MeasurementTransformer | ||
|
||
|
||
class ECHCheckTransformer(MeasurementTransformer): | ||
def make_observations(self, msmt: ECHCheck) -> Tuple[List[WebObservation]]: | ||
dns_observations = [] | ||
tcp_observations = [] | ||
tls_observations = [] | ||
|
||
if msmt.test_keys.queries: | ||
dns_observations = self.make_dns_observations(msmt.test_keys.queries) | ||
if msmt.test_keys.tcp_connect: | ||
tcp_observations = self.make_tcp_observations(msmt.test_keys.tcp_connect) | ||
|
||
if msmt.test_keys.tls_handshakes: | ||
tls_observations = self.make_tls_observations( | ||
tls_handshakes=msmt.test_keys.tls_handshakes, | ||
network_events=msmt.test_keys.network_events, | ||
) | ||
elif msmt.test_keys.control and msmt.test_keys.target: | ||
target = msmt.test_keys.target | ||
target.echconfig = "GREASE" | ||
tls_observations = self.make_tls_observations( | ||
tls_handshakes=[msmt.test_keys.control, target], | ||
network_events=msmt.test_keys.network_events, | ||
) | ||
|
||
return (self.consume_web_observations( | ||
dns_observations=dns_observations, | ||
tcp_observations=tcp_observations, | ||
tls_observations=tls_observations, | ||
http_observations=[] | ||
), ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters