mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: add property ip to Connection entity
parent
3d46a2c473
commit
7d17c05409
|
@ -70,7 +70,8 @@ public class FinalUser {
|
|||
public JsonObject toJson() {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("id", id);
|
||||
json.addProperty("location", this.location != null ? this.location.toString() : "unknown");
|
||||
json.addProperty("ip", this.location.getIp());
|
||||
json.addProperty("location", this.location.toString());
|
||||
json.addProperty("platform", platform);
|
||||
|
||||
JsonObject connectionsJson = new JsonObject();
|
||||
|
|
|
@ -1133,6 +1133,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
// Generate the location for the IpCam
|
||||
GeoLocation location = null;
|
||||
URL url = null;
|
||||
InetAddress ipAddress = null;
|
||||
String protocol = null;
|
||||
try {
|
||||
Pattern pattern = Pattern.compile("^(file|rtsp)://");
|
||||
|
@ -1149,13 +1150,14 @@ public class KurentoSessionManager extends SessionManager {
|
|||
}
|
||||
|
||||
try {
|
||||
location = this.geoLocationByIp.getLocationByIp(InetAddress.getByName(url.getHost()));
|
||||
ipAddress = InetAddress.getByName(url.getHost());
|
||||
location = this.geoLocationByIp.getLocationByIp(ipAddress);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
location = null;
|
||||
location = new GeoLocation(ipAddress.getHostAddress());
|
||||
} catch (Exception e) {
|
||||
log.warn("Error getting address location: {}", e.getMessage());
|
||||
location = null;
|
||||
location = new GeoLocation(ipAddress.getHostAddress());
|
||||
}
|
||||
|
||||
String rtspConnectionId = kMediaOptions.getTypeOfVideo() + "_" + protocol + "_"
|
||||
|
@ -1204,7 +1206,8 @@ public class KurentoSessionManager extends SessionManager {
|
|||
boolean initByServer, boolean forciblyReconnect) {
|
||||
KurentoParticipant kParticipant = (KurentoParticipant) participant;
|
||||
KurentoSession kSession = kParticipant.getSession();
|
||||
reconnectSubscriber(kSession, kParticipant, streamId, sdpString, transactionId, initByServer, forciblyReconnect);
|
||||
reconnectSubscriber(kSession, kParticipant, streamId, sdpString, transactionId, initByServer,
|
||||
forciblyReconnect);
|
||||
}
|
||||
|
||||
private String mungeSdpOffer(Session kSession, Participant participant, String sdpOffer, boolean isPublisher) {
|
||||
|
|
|
@ -205,11 +205,11 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
location = this.geoLocationByIp.getLocationByIp(remoteAddress);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
location = null;
|
||||
location = new GeoLocation(remoteAddress.getHostAddress());
|
||||
} catch (Exception e) {
|
||||
log.warn("Couldn't locate IP address {} in geolocation database: {}", remoteAddress.getHostAddress(),
|
||||
e.getMessage());
|
||||
location = null;
|
||||
location = new GeoLocation(remoteAddress.getHostAddress());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@ public class GeoLocation {
|
|||
private Double latitude;
|
||||
private Double longitude;
|
||||
|
||||
public GeoLocation(String ip) {
|
||||
super();
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public GeoLocation(String ip, String country, String city, String timezone, Double latitude, Double longitude) {
|
||||
super();
|
||||
this.ip = ip;
|
||||
|
@ -45,6 +50,9 @@ public class GeoLocation {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.country == null) {
|
||||
return "unknown";
|
||||
}
|
||||
String location = this.country;
|
||||
if (this.city != null) {
|
||||
location = this.city + ", " + location;
|
||||
|
|
|
@ -47,9 +47,9 @@ import io.openvidu.test.browsers.utils.RecordingUtils;
|
|||
public class AbstractOpenViduTestAppE2eTest {
|
||||
|
||||
final protected String DEFAULT_JSON_SESSION = "{'id':'STR','object':'session','sessionId':'STR','createdAt':0,'mediaMode':'STR','recordingMode':'STR','defaultRecordingProperties':{'hasVideo':true,'frameRate':25,'hasAudio':true,'shmSize':536870912,'name':'','outputMode':'COMPOSED','resolution':'1280x720','recordingLayout':'BEST_FIT'},'customSessionId':'STR','connections':{'numberOfElements':0,'content':[]},'recording':false,'forcedVideoCodec':'STR','allowTranscoding':false}";
|
||||
final protected String DEFAULT_JSON_PENDING_CONNECTION = "{'id':'STR','object':'connection','type':'WEBRTC','status':'pending','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':null,'location':null,'platform':null,'token':'STR','serverData':'STR','record':true,'role':'STR','kurentoOptions':null,'rtspUri':null,'adaptativeBitrate':null,'onlyPlayWithSubscribers':null,'networkCache':null,'clientData':null,'publishers':null,'subscribers':null}";
|
||||
final protected String DEFAULT_JSON_ACTIVE_CONNECTION = "{'id':'STR','object':'connection','type':'WEBRTC','status':'active','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':0,'location':'STR','platform':'STR','token':'STR','serverData':'STR','record':true,'role':'STR','kurentoOptions':null,'rtspUri':null,'adaptativeBitrate':null,'onlyPlayWithSubscribers':null,'networkCache':null,'clientData':'STR','publishers':[],'subscribers':[]}";
|
||||
final protected String DEFAULT_JSON_IPCAM_CONNECTION = "{'id':'STR','object':'connection','type':'IPCAM','status':'active','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':0,'location':'STR','platform':'IPCAM','token':null,'serverData':'STR','record':true,'role':null,'kurentoOptions':null,'rtspUri':'STR','adaptativeBitrate':true,'onlyPlayWithSubscribers':true,'networkCache':2000,'clientData':null,'publishers':[],'subscribers':[]}";
|
||||
final protected String DEFAULT_JSON_PENDING_CONNECTION = "{'id':'STR','object':'connection','type':'WEBRTC','status':'pending','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':null,'location':null,'ip':null,'platform':null,'token':'STR','serverData':'STR','record':true,'role':'STR','kurentoOptions':null,'rtspUri':null,'adaptativeBitrate':null,'onlyPlayWithSubscribers':null,'networkCache':null,'clientData':null,'publishers':null,'subscribers':null}";
|
||||
final protected String DEFAULT_JSON_ACTIVE_CONNECTION = "{'id':'STR','object':'connection','type':'WEBRTC','status':'active','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':0,'location':'STR','ip':'STR','platform':'STR','token':'STR','serverData':'STR','record':true,'role':'STR','kurentoOptions':null,'rtspUri':null,'adaptativeBitrate':null,'onlyPlayWithSubscribers':null,'networkCache':null,'clientData':'STR','publishers':[],'subscribers':[]}";
|
||||
final protected String DEFAULT_JSON_IPCAM_CONNECTION = "{'id':'STR','object':'connection','type':'IPCAM','status':'active','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':0,'location':'STR','ip':'STR','platform':'IPCAM','token':null,'serverData':'STR','record':true,'role':null,'kurentoOptions':null,'rtspUri':'STR','adaptativeBitrate':true,'onlyPlayWithSubscribers':true,'networkCache':2000,'clientData':null,'publishers':[],'subscribers':[]}";
|
||||
final protected String DEFAULT_JSON_TOKEN = "{'id':'STR','token':'STR','connectionId':'STR','createdAt':0,'session':'STR','role':'STR','data':'STR','kurentoOptions':{}}";
|
||||
|
||||
protected static String OPENVIDU_SECRET = "MY_SECRET";
|
||||
|
|
Loading…
Reference in New Issue