summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/base/models/Transport.java
blob: 90a033ddb85f9fa538c7fe2909da40f46e57bb64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package se.leap.bitmaskclient.base.models;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import org.json.JSONObject;

public class Transport {
    private String type;
    private String[] protocols;
    private String[] ports;
    private Options options;

    public Transport(String type, String[] protocols, String[] ports, String cert) {
        this.type = type;
        this.protocols = protocols;
        this.ports = ports;
        this.options = new Options(cert);
    }

    @Override
    public String toString() {
        return new Gson().toJson(this);
    }

    public static Transport fromJson(JSONObject json) {
        GsonBuilder builder = new GsonBuilder();
        return builder.create().fromJson(json.toString(), Transport.class);
    }

    public static class Options {
        private String cert;
        private String iatMode;

        public Options(String cert) {
            this.cert = cert;
            this.iatMode = "0";
        }

        @Override
        public String toString() {
            return new Gson().toJson(this);
        }
    }


}