0

ドメインの Java で org.xbill.DNS を使用して SRV レコードを取得しようとしています

現在、私のドメイン (例: example.com) には次の設定があります。

記録:

HostName:         ramuh
IP Address/URL:   1.1.1.1   // the public ip of my computer
Record Type:      A (Address)

そして、次の SRV レコードを作成しました。

_SERVICE  :        _rdp
_PROTOCOL :        _tcp
PRIORITIY :        1
WEIGHT    :        1
PORT      :        5000      
TARGET    :        ramuh.example.com

私が使用しているクエリ文字列:

_rdp._tcp.ramuh.example.com

ramuh.example.com の SRV レコードを取得できるようにしたいと考えています。

だから私は構築することができます:

ramuh.example.com:5000 (それは、私の側からではなく、自動的に 1.1.1.1:5000 に変換されます)

現在、このコードを使用しています (s は、SRV レコードのリストを返す必要がある入力ドメインです):

    String s = "ramuh.example.com";  // the inputted string, I need to obtain the Port to be added to this
    ArrayList<String> ret = new ArrayList<String>();
    String query = "_rdp._tcp." + s;
    try{
        Record[] records = new Lookup(query,Type.SRV).run();  // returning null
        if(records!= null && records.length>0) {
            for(Record r : records){
                SRVRecord srv = (SRVRecord)r;
                String hostname = srv.getTarget().toString().replaceFirst("\\.$","");
                int port = srv.getPort();
                ret.add(hostname+":"+port);
            }
            return ret;
        }
        else{
           return null;
        }
    }catch(TextParseException e){
        return null;
    }

new Lookup() は null を返すため、渡されるクエリ文字列が無効であると想定します。これを機能させるには、クエリ文字列または SRV レコードに対してどのような変更を行う必要がありますか?

namecheap をドメインとして使用します。

ありがとう

4

1 に答える 1